package com.qiaodata.datatrans.transfor;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.qiaodata.datatrans.entity.*;
import com.qiaodata.datatrans.utils.*;
import org.bson.types.ObjectId;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;


/**
 * 输入json转为输出符合标准的json
 * @author Administrator
 *
 */
@Service
public class OutDataToFormat {

	private static Map<String, String> qdAreaList;
	private static Map<String,String> qzAreaList;
	private static Map<String,String> qDJobList;
	private static Map<String,String> qDTradeList;
	private static Map<String,String> qzHukouList;
	private static Map<String,String> qzJobList;
	private static Map<String,String> qzTradeList;

	public void readTxtToMap(String path) throws ParseException, IOException {
		File file = new File(path);
//        String strTxt = path + "//error.txt";
		//记录错误的信息
//        FileWriter fw1 = new FileWriter(strTxt);//本地模式存储
		if (file.exists()) {
			LinkedList<File> list = new LinkedList<File>();
			File[] files = file.listFiles();// 该文件目录下文件全部放入数组
			for (File file2 : files) {
				String fileName = file2.getName();
				if (file2.isDirectory()) {
					System.out.println("文件夹:" + file2.getAbsolutePath());
					list.add(file2);
				} else if (fileName.endsWith("txt")){
					System.out.println("文件:" + file2.getAbsolutePath());
					//拿到文件
					String filePath =file2.getAbsolutePath();
					List<String> lines = ReadTxtUtil.readTxtFile(filePath);//按行读取txt文档
					if ("qiaodaAreas.txt".equals(fileName)) {
						//加载内容到内存
						if (qdAreaList==null) {
							qdAreaList = new HashMap<String, String>();
							for (String str : lines) {
								String[] split = str.split(",");
								String s = split[0];//字典值
								String s1 = split[1];//对应地名
								qdAreaList.put(split[1], split[0]);//split[0]//字典值--split[1]//对应地名
							}
							System.out.println("qiaodaAreas.txt数据加载完");
						}
					}
					if ("quanzhiAreas.txt".equals(fileName)) {
						if (qzAreaList==null) {
							qzAreaList = new HashMap<String, String>();
							for (String str : lines) {
								String[] split = str.split("\t");
								qzAreaList.put(split[1],split[2]);//split[1]//字典值--split[2]//对应地名
							}
							System.out.println("quanzhiAreas.txt数据加载完");
						}
					}
					if ("qiaodaJob.txt".equals(fileName)) {
						if (qDJobList==null) {
							qDJobList = new HashMap<String,String>();
							for (String str : lines) {
								String[] split = str.split("\t");
								qDJobList.put(split[1],split[0]);//split[1]//中文名--split[0]//字典值
							}
							System.out.println("qiaodaJob.txt数据加载完");
						}
					}
					if ("qiaodaTrade.txt".equals(fileName)) {
						if (qDTradeList==null) {
							qDTradeList = new HashMap<String,String>();
							for (String str : lines) {
								String[] split = str.split("\t");
								qDTradeList.put(split[1],split[0]);//split[1]//中文名--split[0]//字典值
							}
							System.out.println("qiaodaTrade.txt数据加载完");
						}
					}
					if ("quanzhiHukou.txt".equals(fileName)) {
						if (qzHukouList==null) {
							qzHukouList = new HashMap<String,String>();
							for (String str : lines) {
								String[] split = str.split("\t");
								qzHukouList.put(split[2],split[1]);//split[1]//字典值--split[2]//对应地名
							}
							System.out.println("quanzhiHukou.txt数据加载完");
						}
					}
					if ("quanzhiIndustry.txt".equals(fileName)) {
						if (qzTradeList==null) {
							qzTradeList = new HashMap<String,String>();
							for (String str : lines) {
								String[] split = str.split("\t");
								qzTradeList.put(split[1],split[2]);//split[1]//中文名--split[0]//字典值
							}
							System.out.println("quanzhiIndustry.txt数据加载完");
						}
					}
					if ("quanzhiJob.txt".equals(fileName)) {
						if (qzJobList==null) {
							qzJobList = new HashMap<String,String>();
							for (String str : lines) {
								String[] split = str.split("\t");
								qzJobList.put(split[1],split[2]);//split[1]//字典值--split[2]//对应中文名
							}
							System.out.println("quanzhiJob.txt数据加载完");
						}
					}
					//处理文件数据

				} else {
					continue;
				}
			}
			//处理数据
//			String s = qzAreaList.get(dicNumber);
//			String s1 = qdAreaList.get(s);
//			return s1;

		} else {
			System.out.println("文件不存在!");
//			return null;
		}

	}

	public String getQdArea(String regionName) throws IOException {
		if (qdAreaList==null) {
			return null;
		}
		String value = qdAreaList.get(regionName);
		if (value==null || "".equals(value)) {
			return null;
		}
		return value;
	}

	public static String getQdJob(String dicNumber) throws IOException {
		if (qDJobList==null) {
			return null;
		}
		String cnName = qDJobList.get(dicNumber);
		if (cnName==null || "".equals(cnName)) {
			return null;
		}
		return cnName;
	}

	public String getQdTrade(String dicNumber) throws IOException {
		if (qDTradeList==null) {
			return null;
		}
		String cnName = qDTradeList.get(dicNumber);
		if (cnName==null || "".equals(cnName)) {
			return null;
		}
		return cnName;
	}

	public String getQzArea(String dicNumber) throws IOException {
		if (qzAreaList==null) {
			return null;
		}
		String regionName = qzAreaList.get(dicNumber);
		if (regionName==null || "".equals(regionName)) {
			return null;
		}
		return regionName;
	}

	/**
	 * 获取户口字典--用原文查hukou字典得到id，拿id查全职的area，得到转换后的户口中文名，再拿该名查巧达的字典
	 * @param name
	 * @return
	 * @throws IOException
	 */
	public String getQzHukou(String name) throws IOException {
		if (qzHukouList==null) {
			return null;
		}
		String id = qzHukouList.get(name);
		String qzArea = getQzArea(id);
		String qdArea = getQdArea(qzArea);
//		if (qzArea==null || "".equals(qzArea)) {
//			return null;
//		}
		if (qdArea==null || "".equals(qdArea)) {
			qdArea = "0";
		}
		return qdArea;
	}

	public String getQzJob(String dicNumber) throws IOException {
		if (qzJobList==null) {
			return null;
		}
		String cnName = qzJobList.get(dicNumber);
		if (cnName==null || "".equals(cnName)) {
			return null;
		}
		return cnName;
	}

	public String getQzTrade(String dicNumber) throws IOException {
		if (qzTradeList==null) {
			return null;
		}
		String cnName = qzTradeList.get(dicNumber);
		if (cnName==null || "".equals(cnName)) {
			return null;
		}
		return cnName;
	}

	public MetaInfo getMetaInfo(JSONObject jsonIn1, JSONObject jsonIn2, ResumeTags resumeTags){
		MetaInfo metaInfo = new MetaInfo();
		if (jsonIn2==null||"".equals(jsonIn2.toString())) {
			//构造MetaInfo
			metaInfo.setBiz_code("");
			metaInfo.setBiz_id("");
			metaInfo.setEdus(0l);
			metaInfo.setFile_path("");
			metaInfo.setFile_size(0l);
			metaInfo.setFile_type("");
			metaInfo.setOrg_file_path("");
			metaInfo.setOrg_name("");
			metaInfo.setParsed_count(0l);
			metaInfo.setProjects(0l);
			metaInfo.setRate(0.0);
			metaInfo.setResume_size(0l);
			metaInfo.setSys_ver(0l);
			metaInfo.setTemplate_name("");
			metaInfo.setWorks(0l);
			metaInfo.setResumeTags(resumeTags);
		}else {
			JSONObject workExperience = (JSONObject) jsonIn2.get("WorkExperience");
			JSONArray work;
			if (workExperience==null) {
				work = null;
			} else {
				work = (JSONArray) workExperience.get("Work");
			}
			long ws;
			if (work==null) {
				ws = 0l;
			} else {
				ws = work.size();
			}
			JSONObject educationBackground = (JSONObject) jsonIn2.get("EducationBackground");
			JSONArray education;
			if (educationBackground==null) {
				education = null;
			} else {
				education = (JSONArray) educationBackground.get("Education");
			}
			long educations;
			if (education==null) {
				educations = 0l;
			} else {
				educations = education.size();
			}

			//构造MetaInfo
			metaInfo.setBiz_code("v3");//简历业务来源// 纷简历：fen，	V3合并：v3，	乔大招：qdz,    模板生产：tp-id
			metaInfo.setBiz_id("");//对应业务的简历唯一标识// 如乔大招 简历id，原网站简历ID(关联ID，暂时留空)
			metaInfo.setEdus(educations);//教育经历数
			metaInfo.setFile_path("");//文档路径,           	// 原文档存储路径，包括文件名
			metaInfo.setFile_size(0l);//原文件大小// 原文件大小（字节数）
			metaInfo.setFile_type("");//文档类型
			metaInfo.setOrg_file_path("");//"更名前文档路径"
			metaInfo.setOrg_name("");//原始文档路径
			metaInfo.setParsed_count(0l);//已解析字段数量
			metaInfo.setProjects(0l);//项目经历数
			metaInfo.setRate(0.0);//解析比率 // 模板对应的解析比率
			metaInfo.setResume_size(0l);//简历内容数据大小"      // 简历内容数据大小（解析结果字符串(resume_info)大小，字节数，为将来比较简历用）
			metaInfo.setSys_ver(201509l);//解析系统版本，默认201509//解析版本，系统重大更新变更，默认2015。为将来区分数据保留
			metaInfo.setTemplate_name("");
			metaInfo.setWorks(ws);//工作经历数
			metaInfo.setResumeTags(resumeTags);
		}

		return metaInfo;
	}

	public PositionInfo getPositionInfo(JSONObject jsonIn1, JSONObject jsonIn2) throws IOException {
		PositionInfo positionInfo = new PositionInfo();
		if (jsonIn2==null||"".equals(jsonIn2.toString())) {
			//构造PositionInfo
			positionInfo.setCompany("");
			positionInfo.setLocation(0l);
			positionInfo.setLocation_cnt("");
			positionInfo.setPosition("");
		}else {
			JSONObject targetJob = (JSONObject) jsonIn2.get("TargetJob");
			String targetJobCity = jsonIn2.get("TargetJobCity")==null?"":jsonIn2.get("TargetJobCity").toString();
			String currentJobTitle_cn = targetJob.get("CurrentJobTitle_CN")==null?"":targetJob.get("CurrentJobTitle_CN").toString();
			String city = getCity(targetJobCity);
			String cityCnt = getCityCnt(targetJobCity);
			//构造PositionInfo
			positionInfo.setCompany("");//公司名称
			if (city==null) {
				positionInfo.setLocation(0l);//工作地点
			} else {
				positionInfo.setLocation(Long.valueOf(city));//工作地点
			}
			if (cityCnt==null) {
				return null;
			} else {
				positionInfo.setLocation_cnt(cityCnt);//工作地点原文
			}
			positionInfo.setPosition(currentJobTitle_cn);//职位名称
		}
		return positionInfo;
	}

	public JobIntension getJobIntension(JSONObject jsonIn1, JSONObject jsonIn2) throws IOException {
		JobIntension jobIntension = new JobIntension();
		if (jsonIn2==null||"".equals(jsonIn2.toString())) {
			//构造JobIntension
			jobIntension.setArrival_cnt("");//到岗时间原文
			jobIntension.setArrival_time(0l);//["期望行业原文"]
			jobIntension.setCompany_type(0l);//期望单位性质
			jobIntension.setCompany_type_cnt("");//期望单位性质原文
			jobIntension.setCur_salary_cnt("");//当前收入原文
			jobIntension.setCur_salary_from(0l);//当前收入（低限）
			jobIntension.setCur_salary_to(0l);//当前收入（高限）
			jobIntension.setHope_salary_cnt("");//期望收入原文
			jobIntension.setHope_salary_from(0l);//期望工作薪资，起点
			jobIntension.setHope_salary_to(0l);//期望工作薪资，高点
			jobIntension.setJob_nature(0l);//期望工作性质//全职:1 兼职:2  实习:3  全/兼职:4
			jobIntension.setJob_nature_cnt("");//期望工作性质原文
			jobIntension.setState(0l);//目前状态//在找工作:1  目前满意，有更好的工作可以考虑:2    暂时不想找工作:3
			jobIntension.setState_cnt("");//状态原文
			Long[] job = new Long[2];
			Long[] trade = new Long[2];
			job[0] = 0l;
			job[1] = 0l;
			jobIntension.setJob(job);//["期望工作"]//======== 需要字典职位 ========
			String[] Job_cnt = new String[2];
			Job_cnt[0] = "";
			Job_cnt[1] = "";
			jobIntension.setJob_cnt(Job_cnt);//["期望工作原文"]
			Long[] cityL = new Long[1];
			cityL[0]=0l;
			String[] cityCntS = new String[1];
			cityCntS[0] = "";
			jobIntension.setCity(cityL);//["期望工作地"]//======== 需要字典 ========
			jobIntension.setTrade(trade);//["期望行业"]//======== 需要字典行业 ========
			jobIntension.setCity_cnt(cityCntS);//["期望工作地原文"]
			jobIntension.setTrade_cnt(Job_cnt);//["期望行业原文"]
		}else {
			JSONObject targetJob = (JSONObject) jsonIn2.get("TargetJob");
			String targetCity = jsonIn2.get("TargetJobCity")==null?"":jsonIn2.get("TargetJobCity").toString();
			String targetJobType = targetJob.get("TargetJobType")==null?"":targetJob.get("TargetJobType").toString();
			String currentIndustry = jsonIn2.get("CurrentIndustry")==null?"":jsonIn2.get("CurrentIndustry").toString();
			String targetJobProfession = targetJob.get("TargetJobProfession")==null?"":targetJob.get("TargetJobProfession").toString();
			Object careerStatus = jsonIn1.get("CareerStatus");
			if(careerStatus==null || "".equals(careerStatus.toString())) {
				jobIntension.setState(0l);//目前状态//在找工作:1  目前满意，有更好的工作可以考虑:2    暂时不想找工作:3
				jobIntension.setState_cnt("");//状态原文
			} else {
				Map<String, String> stateAndCnt = getStateAndCnt(careerStatus.toString());
				jobIntension.setState_cnt(stateAndCnt.get("state_cnt").toString());//状态原文
				jobIntension.setState(Long.valueOf(stateAndCnt.get("state").toString()));//目前状态//在找工作:1  目前满意，有更好的工作可以考虑:2    暂时不想找工作:3
			}
			Object onBoardTime = targetJob.get("OnBoardTime");
            //构造JobIntension
            if (onBoardTime==null || "".equals(onBoardTime.toString()) || "null".equals(onBoardTime)) {
                jobIntension.setArrival_cnt("");//到岗时间原文
            } else {
				Map<String, String> arrivalAndCntMap = getArrivalAndCnt(onBoardTime.toString());
				jobIntension.setArrival_time(Long.valueOf(arrivalAndCntMap.get("arrival_time")));//到岗时间
				jobIntension.setArrival_cnt(arrivalAndCntMap.get("arrival_cnt"));//到岗时间原文
            }
			jobIntension.setCompany_type(0l);//期望单位性质
			jobIntension.setCompany_type_cnt("");//期望单位性质原文
            Object currentSalary = targetJob.get("CurrentSalary");
            if (currentSalary==null || "".equals(currentIndustry.toString())) {
				jobIntension.setCur_salary_cnt("0"+"-"+"0"+"元/月");//当前收入原文
				jobIntension.setCur_salary_from(Long.valueOf(0));//当前收入（低限）
				jobIntension.setCur_salary_to(Long.valueOf(0));//当前收入（高限）
			} else {
				jobIntension.setCur_salary_cnt(currentSalary.toString()+"-"+currentSalary.toString()+"元/月");//当前收入原文
				try {
					jobIntension.setCur_salary_from(Long.valueOf(currentSalary.toString()));//当前收入（低限）
					jobIntension.setCur_salary_to(Long.valueOf(currentSalary.toString()));//当前收入（高限）
				} catch (Exception e) {
					jobIntension.setCur_salary_from(Long.valueOf(0));//当前收入（低限）
					jobIntension.setCur_salary_to(Long.valueOf(0));//当前收入（高限）
				}
			}

			Object targetSalary = targetJob.get("TargetSalary");
			if (targetSalary==null || "".equals(targetSalary.toString())) {
				jobIntension.setHope_salary_cnt("0"+"-"+"0"+"元/月");//期望收入原文
				jobIntension.setHope_salary_from(Long.valueOf(0));//期望工作薪资，起点
				jobIntension.setHope_salary_to(Long.valueOf(0));//期望工作薪资，高点
			} else {
				jobIntension.setHope_salary_cnt(targetSalary.toString()+"-"+targetSalary.toString()+"元/月");//期望收入原文
				jobIntension.setHope_salary_from(Double.valueOf(targetSalary.toString()).longValue());//期望工作薪资，起点
				jobIntension.setHope_salary_to(Double.valueOf(targetSalary.toString()).longValue());//期望工作薪资，高点
			}
			Map<String, String> jobNature = getJobNature(targetJobType);
			jobIntension.setJob_nature(Long.valueOf(jobNature.get("job_nature")));//期望工作性质//全职:1 兼职:2  实习:3  全/兼职:4
			jobIntension.setJob_nature_cnt(jobNature.get("job_nature_cnt"));//期望工作性质原文

			Long[] ss = new Long[1];
			String[] ss1 = new String[1];
			ss[0] = 0l;
			Long[] job = new Long[1];
			job[0]=0l;
            if (targetJobProfession==null || "".equals(targetJobProfession)) {
				jobIntension.setJob(job);//["期望工作"]//======== 需要字典职位 ========
				jobIntension.setJob_cnt("".split(","));//["期望工作原文"]
            }
			Map<String, String[]> jobAndCnt = getJobAndCnt(targetJobProfession);
			if (jobAndCnt==null) {
				jobIntension.setJob(job);//["期望工作"]//======== 需要字典职位 ========
				jobIntension.setJob_cnt("".split(","));//["期望工作原文"]
			} else {
				String[] jobs1 = jobAndCnt.get("job");
				int length = jobs1.length;
				Long[] jobs = new Long[length];

				for (int i=0; i<length; i++) {
					if ("".equals(jobs1[i])) {
						jobs1[i]="0";
					}
					String s = jobs1[i];
					try {
						jobs[i] = Long.valueOf(s);
					} catch (Exception e) {
						jobs[i] = 0l;
					}

				}
				jobIntension.setJob(jobs);//["期望工作"]//======== 需要字典职位 ========
				jobIntension.setJob_cnt(jobAndCnt.get("job_cnt"));//["期望工作原文"]
			}
			String city = getCity(targetCity);
			if (city==null) {
				jobIntension.setCity(ss);//["期望工作地"]//======== 需要字典 ========
			} else {
				ss[0]=Long.valueOf(city);
				jobIntension.setCity(ss);//["期望工作地"]//======== 需要字典 ========
			}
			String cityCnt = getCityCnt(targetCity);
			if (cityCnt==null) {
//				ss1[0]="";
				jobIntension.setCity_cnt("".split(","));//["期望工作地原文"]
			}
			ss1[0]=cityCnt;
			jobIntension.setCity_cnt(ss1);//["期望工作地原文"]
			Long[] trade = new Long[1];
			trade[0] = 0l;
			if (currentIndustry==null || "".equals(currentIndustry)) {
				jobIntension.setTrade(trade);//["期望行业"]//======== 需要字典行业 ========
				jobIntension.setTrade_cnt("".split(","));//["期望行业原文"]
            }else {
				Map<String, String[]> tradeAndCnt = getTradeAndCnt(currentIndustry);
				if (tradeAndCnt==null) {
					jobIntension.setTrade(trade);//["期望行业"]//======== 需要字典行业 ========
					jobIntension.setTrade_cnt("".split(","));//["期望行业原文"]
				} else {
					String[] tra = tradeAndCnt.get("trade");
					int length = tradeAndCnt.get("trade").length;
					Long[] trades = new Long[length];
					for (int i=0; i<length; i++) {
						if ("".equals(tra[i])) {
							tra[i]="0";
						}
						String s = tra[i];

						try {
							trades[i] = Long.valueOf(s);
						} catch (Exception e) {
							trades[i] = 0l;
						}
					}
					jobIntension.setTrade(trades);//["期望行业"]//======== 需要字典行业 ========
					jobIntension.setTrade_cnt(tradeAndCnt.get("trade_cnt"));//["期望行业原文"]
				}
            }
		}
		return jobIntension;
	}

	public Map<String, String[]> getJobAndCnt(String targetJobProfession) {
		String[] split = targetJobProfession.split("###");
		Map<String, String[]> map = new HashMap<>();
		String jo = "";
		String joCnt = "";
		if (split==null || "".equals(split)||split.length<1) {
			map.put("job", jo.split(","));
			map.put("job_cnt", joCnt.split(","));
			return map;
		} else {
			int length = split.length;
			HashSet<String> jobSet = new HashSet<>();
			for (int i=0; i<length; i++) {
				String s = split[i];
				String[] split1 = s.split(",");
				for (String str : split1) {
					jobSet.add(str);
				}
			}
			Iterator<String> iterator = jobSet.iterator();
			while(iterator.hasNext()){
				String next = iterator.next();
				String name = qzJobList.get(next);
				String dic = qDJobList.get(name);
				if (name==null && dic==null) {
					continue;
				}
				if (name==null) {
					name="";
				}
				if (dic==null) {
					dic = "0";
				}
				jo = jo + dic +",";
				joCnt = joCnt+ name +",";
			}
//			if ("".equals(jo) || "".equals(joCnt)) {
//				return null;
//			}
			map.put("job", jo.split(","));
			map.put("job_cnt", joCnt.split(","));
			return map;
		}

	}

	/**
	 * 获取找工作状态
	 * @param careerStatus
	 * @return
	 */
	public Map<String, String> getStateAndCnt(String careerStatus) {
		//全职：1正在找工作；2有更好机会，我愿意考虑；3暂时不想找工作
		//巧达：//在找工作:1  目前满意，有更好的工作可以考虑:2    暂时不想找工作:3
		Map<String, String> map = new HashMap<>();
		switch (careerStatus) {
			case "1"://
				map.put("state", "1");
				map.put("state_cnt", "在找工作");
				break;
			case "2":
				map.put("state", "1");
				map.put("state_cnt", "目前满意，有更好的工作可以考虑");
				break;
			case "3":
				map.put("state", "1");
				map.put("state_cnt", "暂时不想找工作");
				break;

			default:
				map.put("state", "");
				map.put("state_cnt", "");
				break;
		}
		return map;
	}

	/**
	 * 全职到岗时间
	 * @param onBoardTime
	 * @return
	 */
	public Map<String, String> getArrivalAndCnt(String onBoardTime) {
		//全职到岗时间：1立即，2一周以内，3两周以内，4一月内，5三月内，6三个月以后，7面议
		//巧达到岗时间：
		Map<String, String> map = new HashMap<String, String>();
		switch (onBoardTime) {
			case "1":
				map.put("arrival_time", "1");
				map.put("arrival_cnt", "可立即上岗");
				break;
			case "2":
				map.put("arrival_time", "2");
				map.put("arrival_cnt", "一周以内");
				break;
			case "3":
				map.put("arrival_time", "3");
				map.put("arrival_cnt", "一个月内");
				break;
			case "4":
				map.put("arrival_time", "3");
				map.put("arrival_cnt", "一个月内");
				break;
			case "5":
				map.put("arrival_time", "4");
				map.put("arrival_cnt", "1-3个月");
				break;
			case "6":
				map.put("arrival_time", "5");
				map.put("arrival_cnt", "三个月后");
				break;
			case "7":
				map.put("arrival_time", "6");
				map.put("arrival_cnt", "待定");
				break;

			default:
				map.put("arrival_time", "6");
				map.put("arrival_cnt", "待定");
				break;
		}
		return map;
	}

	public DeliverInfo getDeliverInfo(JSONObject jsonIn1, JSONObject jsonIn2, PositionInfo positionInfo, JobIntension jobIntension) {
		DeliverInfo deliverInfo = new DeliverInfo();
		try {
			if (jsonIn2==null||"".equals(jsonIn2.toString())) {
				//构造DeliverInfo
				deliverInfo.setSrid("");
				deliverInfo.setAppoint_time(0l);
				deliverInfo.setDisp_time(0l);
				deliverInfo.setRecruit_path("");
				deliverInfo.setRefresh_time(0l);
				deliverInfo.setSid(0l);
				deliverInfo.setUmid("");
				deliverInfo.setUpdate_time(0l);
				deliverInfo.setUserid("");
				deliverInfo.setPositionInfo(positionInfo);
				deliverInfo.setJobIntension(jobIntension);
			}else {
				//构造DeliverInfo
				deliverInfo.setSrid("");
//			deliverInfo.setAppoint_time(getAppointTime(jsonIn2));//指定时间，永远按照最后一份工作的结束时间的规则来获取
				deliverInfo.setAppoint_time(0l);//指定时间，永远按照最后一份工作的结束时间的规则来获取
				deliverInfo.setDisp_time(0l);//简历投递时间，时间戳
				deliverInfo.setRecruit_path("");//招收方式：deliver:投递，download：下载；monitor：监测；collect：收藏；
				deliverInfo.setRefresh_time(getRefreshTime(jsonIn1));//简历最后刷新时间，时间戳
				deliverInfo.setSid(1l);
				deliverInfo.setUmid("");
//			long timeMillis = System.currentTimeMillis()/1000;
				deliverInfo.setUpdate_time(getRefreshTime(jsonIn1));//简历最后更新时间，时间戳
				Object userId = jsonIn2.get("UserId");
				deliverInfo.setUserid(userId.toString());
				deliverInfo.setPositionInfo(positionInfo);
				deliverInfo.setJobIntension(jobIntension);
			}
			return deliverInfo;
		} catch (Exception e) {
			return null;
		}

	}

	public Long getAppointTime(JSONObject jsonIn2) {
		JSONObject jow = (JSONObject) jsonIn2.get("WorkExperience");
		JSONArray joa = (JSONArray) jow.get("Work");
		JSONObject work = (JSONObject) joa.get(0);
		Object endYear = work.get("EndYear");
		if (endYear==null || "".equals(endYear)) {
			return 0l;
		}
		Long aLong = Long.valueOf(endYear.toString());
		if (aLong==2051193600L) {//2051193600代表至今
			return 0l;
		}
		return aLong;
	}

	public Collection<WorkCnt> getWorkCnts(JSONObject jsonIn1, JSONObject jsonIn2) {
		Collection<WorkCnt> workCnts = new LinkedHashSet<>();
		try {
			if (jsonIn2==null||"".equals(jsonIn2.toString())) {
				//构造WorkCnt
				WorkCnt workCnt = new WorkCnt();
				workCnt.setContent("");
				workCnts.add(workCnt);
			}else {
				JSONObject jow = (JSONObject) jsonIn2.get("WorkExperience");
				JSONArray joa;
				if (jow==null) {
					joa = null;
				} else {
					joa = (JSONArray) jow.get("Work");
				}
				int workLength;
				if (joa==null) {
					workLength = 0;
				} else {
					workLength = joa.size();
				}
				Map<String, String> salaryArr = null;
				String content = null;
				for (int i = 0; i < workLength; i++) {
					JSONObject jso = (JSONObject) joa.get(i);
					JSONArray jsoa = (JSONArray) jso.get("Job");
					JSONObject jso1 = (JSONObject) jsoa.get(0);
					Object salary = jso1.get("Salary");
					String salaryStr = "";
					if (salary==null || "".equals(salary.toString()) || "0".equals(salary.toString())) {
						salaryStr = "0";
					}else {
//                    salaryArr = salaryArr(jso1.get("Salary").toString());
						salaryStr = salary.toString();
					}
					String jobTime = jso1.get("JobTime")==null?"":jso1.get("JobTime").toString();
					String companyName_CN = jso.get("CompanyName_CN") == null ? "" : jso.get("CompanyName_CN").toString();
					String jobTitle_CN = jso1.get("JobTitle_CN")==null?"":jso1.get("JobTitle_CN").toString();
					String jobDescription_CN = jso1.get("JobDescription_CN")==null?"":jso1.get("JobDescription_CN").toString();
					content = ""+jobTime.replace("/0-", "/至今").replace("-", ".").replace("/", "-")+" "+companyName_CN
							+" "+jobTitle_CN+"|"+salaryStr+"-"
							+salaryStr+"元/月  "+jobDescription_CN;
					//构造WorkCnt
					WorkCnt workCnt = new WorkCnt();
					workCnt.setContent(content);
					workCnts.add(workCnt);
				}
			}
			return workCnts;
		} catch (Exception e) {
			return null;
		}

	}

	public Collection<Work> getWorks(JSONObject jsonIn1, JSONObject jsonIn2) throws ParseException, IOException {
		//集合
		Collection<Work> works = new LinkedHashSet<>();
		if (jsonIn2==null||"".equals(jsonIn2.toString())) {
			//构造Work
			Work work = new Work();
			work.setAchievements("");
			work.setCompany("");
			work.setCompany_disc("");
			work.setCompany_size_cnt("");
			work.setCompany_type(0l);
			work.setCompany_type_cnt("");
			work.setDepartment("");
			work.setDuty("");
			work.setEtime(0l);
			work.setIm_subordinate(0l);
			work.setJob("");
			work.setJob_description("");
			work.setLocation("");
			work.setPosition_type("");
			work.setReason_of_quit("");
			work.setReport_to("");
			work.setStime(0l);
			work.setSalary_cnt("");
			work.setSalary_from(0l);
			work.setSalary_of_mon("");
			work.setSalary_to(0l);
			work.setSubordinate("");
			work.setTime_cnt("");
			work.setTrade(0l);
			work.setTrade_cnt("");

			works.add(work);
		}else {
			JSONObject jow = (JSONObject) jsonIn2.get("WorkExperience");
			JSONArray joa;
			if (jow==null) {
				joa = null;
			} else {
				joa = (JSONArray) jow.get("Work");
			}
			int workLength = 0;
			if (joa==null) {
				workLength = 0;
			}else {
				workLength = joa.size();
			}
			Map<String, String> salaryArr = null;
			Map<String, Long> map = null;
			for (int i = 0; i < workLength; i++) {
				try {
					JSONObject jso = (JSONObject) joa.get(i);
					JSONArray jsoa = (JSONArray) jso.get("Job");
					Object companyInstruction_cn = jso.get("CompanyInstruction_CN");
					String companyInstructionCn = "";
					if (companyInstruction_cn==null || "".equals(companyInstruction_cn.toString())) {
						companyInstructionCn = "";
					} else {
						companyInstructionCn = jso.get("CompanyInstruction_CN").toString();//公司描述
					}
					String compayIndustry = jso.get("CompayIndustry").toString();//公司行业trade
					Map<String, String[]> tradeAndCntMap = getTradeAndCnt(compayIndustry);
					JSONObject jso1 = (JSONObject) jsoa.get(0);
					String companyName_cn = (String) jso.get("CompanyName_CN");
					String jobTitle_cn = (String) jso1.get("JobTitle_CN");
					String jobDescription_cn = (String) jso1.get("JobDescription_CN");
					String jobTime = (String) jso1.get("JobTime");
					String workPlace_cn = "";
					Object workPlaceObj = jso1.get("WorkPlace_CN");//工作地点
					if (workPlaceObj==null || "".equals(workPlaceObj.toString())) {
						workPlace_cn = "";
					}else {
						workPlace_cn = workPlace_cn.toString();
					}
					Object departmentObj = jso1.get("Department_CN");//所在部门
					String department_cn = "";
					if (departmentObj==null || "".equals(departmentObj.toString())) {
						department_cn = "";
					} else {
						department_cn = departmentObj.toString();
					}
					Work work = new Work();

//				Long salary = (Long) jso1.get("Salary");
					Object salary = jso1.get("Salary");
					if (salary==null) {
						work.setSalary_cnt("");//薪资原文
					}else {
						work.setSalary_cnt(salary.toString());//薪资原文
					}
					//薪水上下限确定
					if (salary==null || "0".equals(salary.toString())) {
						work.setSalary_from(0l);//薪资范围下限
						work.setSalary_to(0l);//薪资范围上限
					} else {
						work.setSalary_from(Long.valueOf(salary.toString()));//薪资范围下限
						work.setSalary_to(Long.valueOf(salary.toString()));//薪资范围上限
					}

					//时间戳确定
					map = getStimeAndEtime(jso1.get("JobTime").toString());
					Map<String, Object> companyNatureMap = getComanyType(jso.get("CompanyNature").toString());//公司性质
					//构造Work
					work.setAchievements("");//业绩
					work.setCompany(companyName_cn);//公司名称
					work.setCompany_disc(companyInstructionCn);//公司描述",		// new
					Object companySize = jso.get("CompanySize");
					if (companySize==null) {
						work.setCompany_size_cnt("");
					}else {
						work.setCompany_size_cnt(getCompanySizeCnt(jso.get("CompanySize").toString()));//公司规模原文
					}

					work.setCompany_type(Long.valueOf(companyNatureMap.get("type").toString()));//公司性质//======== 需要字典确认公司类型 ========
					work.setCompany_type_cnt(companyNatureMap.get("type_cnt").toString());//公司性质原文
					work.setDepartment(department_cn);//部门
					work.setDuty("");//职责
					work.setEtime(map.get("etime"));//离职时间yyyyMMdd
					work.setIm_subordinate(0l);//直接下属
					work.setJob(jobTitle_cn);//工作职位
					work.setJob_description(jobDescription_cn);//工作描述
					work.setLocation(workPlace_cn);//所在地区",		// new
					work.setPosition_type("");//职位类别",	// new  ??? 什么值？
					work.setReason_of_quit("");//离职原因
					work.setReport_to("");//汇报对象
					work.setStime(map.get("stime"));//入职时间yyyyMMdd

					work.setSalary_of_mon("");

					work.setSubordinate("");//下属
					work.setTime_cnt(getWorkTimeCnt(jobTime));//工作时间原文
					if (tradeAndCntMap==null) {
						//工作经历的行业可以为空
						work.setTrade(0l);//行业	//======== 需要字典确认行业 ========
						work.setTrade_cnt("");//行业原文
					} else {
						work.setTrade(Long.valueOf(tradeAndCntMap.get("trade")[0]));//行业	//======== 需要字典确认行业 ========
						work.setTrade_cnt(tradeAndCntMap.get("trade_cnt")[0]);//行业原文
					}
					works.add(work);
				} catch (Exception e) {
					continue;
				}
			}
		}
		return works;

	}

	/**
	 * 公司规模
	 * @param companySize
	 * @return
	 */
	public String getCompanySizeCnt(String companySize) {
		String str="";
		switch (companySize) {
			case "1":
				str = "少于50人";
				break;
			case "2":
				str = "50-100人";
				break;
			case "3":
				str = "100-500人";
				break;
			case "4":
				str = "500-1000人";
				break;
			default:
				str = "1000-5000人";
				break;
		}
		return str;
	}

	/**
	 * 获取公司性质
	 * @param companyNature
	 * @return
	 */
	public Map<String, Object> getComanyType(String companyNature) {
		Map<String, Object> map = new HashMap<>();
		switch (companyNature) {
			case "1":
				map.put("type", 1l);
				map.put("type_cnt", "外资");
				break;
			case "2":
				map.put("type", 1l);
				map.put("type_cnt", "外资");
				break;
			case "3":
				map.put("type", 2l);
				map.put("type_cnt", "合资");
				break;
			case "4":
				map.put("type", 2l);
				map.put("type_cnt", "合资");
				break;
			case "5":
				map.put("type", 3l);
				map.put("type_cnt", "国企");
				break;
			case "6":
				map.put("type", 10l);
				map.put("type_cnt", "上市公司");
				break;
			case "7":
				map.put("type", 10l);
				map.put("type_cnt", "上市公司");
				break;
			case "8":
				map.put("type", 4l);
				map.put("type_cnt", "民营公司");
				break;
			case "9":
				map.put("type", 6l);
				map.put("type_cnt", "政府机关");
				break;
			case "10":
				map.put("type", 7l);
				map.put("type_cnt", "事业单位");
				break;
			default:
				map.put("type", 9l);
				map.put("type_cnt", "其它性质");
				break;
		}
		return map;
	}

	/**
	 * 获取工作时间转换
	 * @param jobTime
	 * @return
	 */
	public String getWorkTimeCnt(String jobTime) {
		String replace = jobTime.replaceAll("-", ".");
		String[] split = replace.split("/");
		if ("0-".equals(split[1]) || "0.".equals(split[1])) {
			split[1]="至今";
		}
		replace = split[0]+"-"+split[1];
		return replace;
	}

	/**
	 * 薪水范围初步确定
	 * @param salary
	 * @return
	 */
	public Map<String, String> salaryArr(String salary) {
		long salaryInt = StringUtil.parseLong(salary);
		//目前先按照上下幅度一千算，等待提供区间计算标准
		long a = salaryInt - 1000;
		long b = salaryInt + 1000;
		Map<String, String> map = new HashMap<String, String>();
		if (a<=0) {
			map.put("salary_from", "0");
		}else {
			map.put("salary_from", ""+a);
		}
		if (b<a) {
			map.put("salary_to", ""+a);
		}else {
			map.put("salary_to", ""+b);
		}
		return map;
	}

	/**
	 * 工作时间解析为开始，离职时间
	 * @param jobTime
	 * @return
	 * @throws ParseException
	 */
	public Map<String, Long> getStimeAndEtime(String jobTime) throws ParseException {
		Map<String, Long> map = new HashMap<>();
		SimpleDateFormat sf = new SimpleDateFormat("yyyy.MM");
		if (StringUtil.notEmpty(jobTime)) {
			String[] split = jobTime.split("/");//时间范围分割
			String s2 = split[1].replace("-", ".");
			String s1 = split[0].replace("-", ".");
			Long te = null;
			//判断时间区间上限是否是当前或者至今，全职网为2013.08 - 至今，对应"2013-08/0-"
			if ("0-".equals(s2) || "0.".equals(s2) || s2.contains("0-") || s2.contains("0.") || s2.contains("至今")) {
				//获取当前时间戳
				te = 0l;
			}else {
				//将字符串日期转化为时间戳
				Date date = sf.parse(s2);
				long time = date.getTime();
				te = Long.valueOf(time/1000);
			}
			map.put("etime", te);
			//将开始字符串日期转化为时间戳
			Date date = sf.parse(s1);
			long time = date.getTime();
			Long ts = Long.valueOf(time/1000);
			map.put("stime", ts);
		}
		return map;
	}

	public String getEmail(JSONObject jsonIn1) {
		String s = "";
		if (jsonIn1==null || "".equals(jsonIn1.toString())) {
			return s;
		}
		String email = (String) jsonIn1.get("Email");
		if (email==null || "".equals(email.trim())) {
			return s;
		}
		return email;
	}

	public String getMobile(JSONObject jsonIn1) {
		String s = "";
		if (jsonIn1==null || "".equals(jsonIn1.toString())) {
			return s;
		}
		String mobile = (String) jsonIn1.get("Mobile");
		if (mobile==null || "".equals(mobile.trim())) {
			return s;
		}
		return mobile;
	}

	public ResumeTags getResumeTags(JSONObject jsonIn1, JSONObject jsonIn2) {
		//PersonalInformation--jsonIn1, Resume--jsonIn2
		//构造ResumeTags
		ResumeTags resumeTags = new ResumeTags();
		if (jsonIn1==null || "".equals(jsonIn1.toString())) {
			resumeTags.setClass_b("");
			resumeTags.setClass_c("");
			resumeTags.setClass_d("");
			resumeTags.setEmail("");
			resumeTags.setName_mobile("");
			resumeTags.setSrid("");
		} else {
			String name_cn = (String) jsonIn1.get("Name_CN");
			String mobile = (String) jsonIn1.get("Mobile");
			String email = (String) jsonIn1.get("Email");
			resumeTags.setClass_b("");//B类// B    无工作经历，n个教育经历：同时搜索匹配这两段的
			resumeTags.setClass_c("");//C类// C	 1工作经历，1教育经历：按（基本信息+教育经历）+ 公司名查询，匹配结果
			resumeTags.setClass_d("");//D类// D	1教育经历，n工作经历：按（基本信息+教育经历）+ n个公司名 查询，匹配结果
			resumeTags.setEmail(email);//邮箱
			resumeTags.setName_mobile(name_cn+"+"+mobile);//姓名+手机号
			resumeTags.setSrid("");//源网站id
		}
		return  resumeTags;
	}

	public Collection<SelfAssessment> getSelfAssessments(JSONObject jsonIn1, JSONObject jsonIn2) {
		Collection<SelfAssessment> selfAssessments = new LinkedHashSet<>();//一条记录
		SelfAssessment selfAssessment = new SelfAssessment();
		if (jsonIn2==null || "".equals(jsonIn2.toString())) {
			//构造SelfAssessment
			selfAssessment.setContent("");
			selfAssessment.setContent_type("");
			selfAssessments.add(selfAssessment);
		}else {
			JSONObject object = (JSONObject) jsonIn2.get("SelfAssessment");
			String content;
			if (object==null || "".equals(object.toString())) {
				content = "";
				selfAssessment.setContent("");//自我评价内容
				selfAssessment.setContent_type("自我评价");//自我评价类型
				selfAssessments.add(selfAssessment);
				return selfAssessments;
			} else {
				content = object.get("Assessment_CN")==null?"":object.get("Assessment_CN").toString();
			}
			Long completeStatus_cn = Long.valueOf(object.get("CompleteStatus_CN")==null?"0":object.get("CompleteStatus_CN").toString());
			if (completeStatus_cn==0l) {
				//构造SelfAssessment
				selfAssessment.setContent("");//自我评价内容
				selfAssessment.setContent_type("自我评价");//自我评价类型
			} else {
				//构造SelfAssessment
				selfAssessment.setContent(content);//自我评价内容
				selfAssessment.setContent_type("自我评价");//自我评价类型
			}
			selfAssessments.add(selfAssessment);
		}
		return selfAssessments;
	}

	public Collection<Certification> getCertifications(JSONObject jsonIn1, JSONObject jsonIn2) throws ParseException {
		Collection<Certification> certifications = new LinkedHashSet<Certification>();
		if (jsonIn2==null || "".equals(jsonIn2.toString())) {
			//构造Certification
			Certification certification = new Certification();
			certification.setCer_name("");
			certification.setDescription("");
			certification.setIssued(0l);
			certifications.add(certification);
			return certifications;
		}else {
			JSONObject certificate = (JSONObject) jsonIn2.get("Certificate");
			JSONArray certificateList;
			if (certificate==null || "".equals(certificate.toString())) {
				certificateList = null;
			} else {
				certificateList = (JSONArray) certificate.get("CertificateList");
			}
			int size;
			if (certificateList==null) {
				size = 0;
			} else {
				size = certificateList.size();
			}
			if (size==0) {
				//构造Certification
				Certification certification = new Certification();
				certification.setCer_name("");
				certification.setDescription("");
				certification.setIssued(0l);
				certifications.add(certification);
				return certifications;
			}
			for (int i=0; i<size; i++) {
				JSONObject certifica = (JSONObject) certificateList.get(i);
				String name_cn = certifica.get("Name_CN")==null?"":(String) certifica.get("Name_CN");
				//构造Certification
				Certification certification = new Certification();
				certification.setCer_name(name_cn);//证书名
				certification.setDescription("");//证书描述
				long obtainTime = (certifica.get("ObtainTime") == null||"".equals(certifica.get("ObtainTime").toString())) ? 0l : TimeUtil.getDateTmp(certifica.get("ObtainTime").toString());
				certification.setIssued(obtainTime);//颁发时间原文
				certifications.add(certification);
			}
		}
		return certifications;
	}

	public Collection<Education> getEducations(JSONObject jsonIn1, JSONObject jsonIn2) throws ParseException {
		//集合
		Collection<Education> educations = new LinkedHashSet<>();
		try {
			if (jsonIn2==null || "".equals(jsonIn2.toString())) {
				//构造Education
				Education education = new Education();
				education.setDescription("");
				education.setBackgd(0l);
				education.setBackgd_cnt("");
				education.setDegree(0l);
				education.setDegree_cnt("");
				education.setEtime(0l);
				education.setSchool("");
				education.setSpeciality("");
				education.setStime(0l);
				education.setTime_cnt("");
				education.setUnified_enrollment("");
				educations.add(education);
			}else {
				JSONObject jsoE = (JSONObject) jsonIn2.get("EducationBackground");
				JSONArray jsoEduArr;
				if (jsoE==null) {
					jsoEduArr=null;
				} else {
					jsoEduArr = (JSONArray) jsoE.get("Education");
				}
				int eduSize;
				if (jsoEduArr==null) {
					eduSize = 0;
				}else {
					eduSize = jsoEduArr.size();
				}
				for (int i = 0; i < eduSize; i++) {
					JSONObject jsoEdu = (JSONObject) jsoEduArr.get(i);
					Education education = new Education();
					Object period = jsoEdu.get("Period");
					if (period==null) {
						education.setEtime(0l);//毕业时间yyyyMM
						education.setStime(0l);//入学时间yyyyMM
					}else {
						Map<String, Long> eduMap = getStimeAndEtime(period.toString());
						education.setEtime(eduMap.get("etime"));//毕业时间yyyyMM
						education.setStime(eduMap.get("stime"));//入学时间yyyyMM
					}

					Map<String, Object> degreeMap = getDegree(jsoEdu.get("Degree")==null?"":jsoEdu.get("Degree").toString());

					//构造Education
					education.setDescription(jsoEdu.get("Description_CN")==null?"":(String) jsoEdu.get("Description_CN"));//描述
					education.setBackgd(Long.valueOf(degreeMap.get("backgd_id")==null?"":degreeMap.get("backgd_id").toString()));//学历
					education.setBackgd_cnt(degreeMap.get("backgd").toString());//学历原文// 初中:1 高中:2 	中技:3  中专:4 大专:5 本科:6 MBA&EMBA:7 硕士:8 博士:9  	其他:10
					Object degree_id = degreeMap.get("degree_id");
					if (degree_id==null || "".equals(degree_id.toString())) {
						education.setDegree(0l);//学位id
					} else {
						education.setDegree(Long.valueOf(degreeMap.get("degree_id").toString()));//学位id
					}
					education.setDegree_cnt(degreeMap.get("degree").toString());//学位原文
					education.setSchool(jsoEdu.get("SchoolName_CN")==null?"":(String) jsoEdu.get("SchoolName_CN"));//学校名称
					education.setSpeciality(jsoEdu.get("MajorName_CN")==null?"":(String) jsoEdu.get("MajorName_CN"));//专业名称
					education.setTime_cnt(jsoEdu.get("Period")==null?"":getWorkTimeCnt(jsoEdu.get("Period").toString()));//教育时间原文
					education.setUnified_enrollment("");//是否统招，否：0，是：1	// new

					educations.add(education);
				}
			}
			return educations;
		} catch (Exception e) {
			return null;
		}
	}


	/**
	 * 获取工作性质值
	 * @param targetJobType
	 * @return
	 */
	public Map<String, String> getJobNature(String targetJobType) {
		//巧达期望工作性质//全职:1 兼职:2  实习:3  全/兼职:4
		//全职期望工作性质 数字表示 0表示未知，全职1，兼职2，短工/临时3，实习4  多选用'-'隔开。
		Map<String, String> map = new HashMap<>();
		switch (targetJobType) {
			case "1":
				map.put("job_nature", "1");
				map.put("job_nature_cnt", "全职");
				break;
			case "2":
				map.put("job_nature", "2");
				map.put("job_nature_cnt", "兼职");
				break;
			case "4":
				map.put("job_nature", "3");
				map.put("job_nature_cnt", "实习");
				break;

			default:
				map.put("job_nature", "4");
				map.put("job_nature_cnt", "全/兼职");
				break;
		}
		return map;
	}

	/**
	 * 全职网学历学位解析
	 * @param degreeStr
	 * @return
	 */
	public Map<String, Object> getDegree(String degreeStr) {
		Map<String, Object> map = new HashMap<>();
		//全职网学历对应关系可能如下，需要最终确定
		switch (degreeStr) {
			case "1":
				map.put("degree", "");
				map.put("degree_id", "");
				map.put("backgd", "初中");
				map.put("backgd_id", 1l);
				break;
			case "2":
				map.put("degree", "");
				map.put("degree_id", "");
				map.put("backgd", "高中");
				map.put("backgd_id", 2l);
				break;
			case "3":
				map.put("degree", "");
				map.put("degree_id", "");
				map.put("backgd", "中专");
				map.put("backgd_id", 4l);
				break;
			case "4":
				map.put("degree", "");
				map.put("degree_id", "");
				map.put("backgd", "大专");
				map.put("backgd_id", 5l);
				break;
			case "5":
				map.put("degree", "学士");
				map.put("degree_id", "6");
				map.put("backgd", "本科");
				map.put("backgd_id", 6l);
				break;
			case "6":
				map.put("degree", "MBA");
				map.put("degree_id", "7");
				map.put("backgd", "MBA&EMBA");
				map.put("backgd_id", 7l);
				break;
			case "7":
				map.put("degree", "硕士");
				map.put("degree_id", "8");
				map.put("backgd", "硕士");
				map.put("backgd_id", 8l);
				break;
			case "8":
				map.put("degree", "博士");
				map.put("degree_id", "9");
				map.put("backgd", "博士");
				map.put("backgd_id", 9l);
				break;

			default:
				map.put("degree", "");
				map.put("degree_id", "");
				map.put("backgd", "其他");
				map.put("backgd_id", 10l);
				break;
		}
		return map;
	}

//	/**
//	 * 获取最高学历
//	 * @param jsonIn1
//	 * @return
//	 * @throws ParseException
//	 */
//	public Map<String, Object> getHighBackgd(JSONObject jsonIn1) {
//		Map<String, Object> map = new HashMap<String, Object>();
//		if (jsonIn1==null || "".equals(jsonIn1.toString())) {
//			map.put("backgd", 0l);
//			map.put("backgd_cnt", "");
//			return map;
//		}
//		Object degree = jsonIn1.get("Degree");
//		if (degree==null || Long.valueOf(degree.toString())==0l) {
//			map.put("backgd", 0l);
//			map.put("backgd_cnt", "");
//			return map;
//		}
//		Map<String, Object> map = getDegree(degree.toString());
//		return map;
// 	}

	public Map<String, Object> getBirthdayInfo(JSONObject jsonIn1) throws ParseException {
        Map<String, Object> map = new HashMap<String, Object>();
        String birthday_cnt = null;
        Long birthday = null;
        if(jsonIn1==null || "".equals(jsonIn1.toString())) {
            map.put("birthday_cnt", "");
            map.put("birthday", 0l);
        }else {
			String birthdayY = "";
			String birthdayM = "";
			String birthdayD ="";
			Object birthdayYObj = jsonIn1.get("BirthdayY");
			Object birthdayMObj = jsonIn1.get("BirthdayM");
			Object birthdayDObj = jsonIn1.get("BirthdayD");
			if (birthdayYObj==null || "".equals(""+birthdayYObj)) {
				birthdayY="";
			} else {
				birthdayY = ""+birthdayYObj;
			}
			if (birthdayMObj==null || "".equals(birthdayMObj.toString())) {
				birthdayM = "01";
			} else {
				birthdayM = birthdayMObj.toString();
			}
			if (birthdayDObj==null || "".equals(birthdayDObj.toString())) {
				birthdayD = "01";
			} else {
				birthdayD = birthdayDObj.toString();
			}
            birthday_cnt = birthdayY + "年" + birthdayM + "月" + birthdayD + "日";
            map.put("birthday_cnt", birthday_cnt);

            if (birthdayY==null || "".equals(birthdayY)) {
                map.put("birthday", 0l);
                return map;
            }
            if (birthdayM==null || "".equals(birthdayM)) {
                String s = jsonIn1.get("BirthdayY").toString();
                SimpleDateFormat sf = new SimpleDateFormat("yyyy");
                Date parse = sf.parse(s);
                long time = parse.getTime() / 1000;
                map.put("birthday", time);
                return map;
            }
            if (birthdayD==null || "".equals(birthdayD)) {
                String s = jsonIn1.get("BirthdayY").toString()+"/"+jsonIn1.get("BirthdayM");
                SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM");
                Date parse = sf.parse(s);
                long time = parse.getTime() / 1000;
                map.put("birthday", time);
                return map;
            }
            String s = jsonIn1.get("BirthdayY").toString()+"/"+birthdayM+"/"+birthdayD;
            SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd");
            Date parse = sf.parse(s);
            long time = parse.getTime() / 1000;
            map.put("birthday", time);
        }
        return map;
    }

    public Map<String, Object> getHigherEducationInfo(JSONObject jsonIn2) {
        Map<String, Object> map = new HashMap<>();
        if (jsonIn2==null || "".equals(jsonIn2.toString())) {
            map.put("newSchoolName_cn", "");
            map.put("newMajorName_cn", "");
        }else {
            String newSchoolName_cn = (String) jsonIn2.get("NewSchoolName_CN");
            String newMajorName_cn = (String) jsonIn2.get("NewMajorName_CN");
            map.put("newSchoolName_cn", newSchoolName_cn);
            map.put("newMajorName_cn", newMajorName_cn);
        }
        return map;
    }

    public String getIdentityType(JSONObject jsonIn2) {
        if (jsonIn2==null || "".equals(jsonIn2.toString())) {
            return "4";
        }
        Object identity = jsonIn2.get("Identity");
        if (identity==null) {
            return  "4";
        }
        return identity.toString();
    }

    /**
     * 获取当前时间戳
     * @return
     */
    public Long getCurrentTime() {
        long l = System.currentTimeMillis() / 1000;
        return l;
    }

	/**
	 * 获取简历投递时间，版本时间
	 * @param jsonIn1
	 * @return
	 */
	public Long getRefreshTime(JSONObject jsonIn1) {
		if (jsonIn1==null || "".equals(jsonIn1.toString())) {
			return null;
		}
		Object deliverTime = jsonIn1.get("AddTime");
		if (deliverTime==null) {
			return null;
		}
		Long time = Double.valueOf(deliverTime.toString()).longValue();
		return time;
	}

	public Map<String, Object> getMarriageState(JSONObject jsonIn1) {
		Map<String, Object> map = new HashMap<String, Object>();
		if (jsonIn1==null || "".equals(jsonIn1.toString())) {
			map.put("marriage_stat", 3L);
			map.put("marriage_cnt", "保密");
			return map;
		}
		Object maritalStatus = jsonIn1.get("MaritalStatus");
		if (maritalStatus==null) {
			map.put("marriage_stat", 3L);
			map.put("marriage_cnt", "保密");
			return map;
		}
		// 巧达  未婚:1  已婚:2  保密:3  离异：4
		switch (""+maritalStatus) {//全职婚姻状况 数字表示   0未知，1已婚，2未婚，3保密
			case "1":
				map.put("marriage_stat", 2L);
				map.put("marriage_cnt", "已婚");
				break;
			case "2":
				map.put("marriage_stat", 1L);
				map.put("marriage_cnt", "未婚");
				break;
			case "3":
				map.put("marriage_stat", 3L);
				map.put("marriage_cnt", "保密");
				break;

			default:
				map.put("marriage_stat", 3L);
				map.put("marriage_cnt", "保密");
				break;
		}
		return map;
	}

	/**
	 * 获取当前城市，经过巧达格式转换后的
	 * @param residence
	 */
	public String getCity(String residence) throws IOException {
		String cityStr = residence;
		String[] split = cityStr.split(",");
		String regionName = "";
		String qdArea = "0";
		int length = split.length;
		if (length==0) {
			return qdArea;
		}
		if (length==1) {
			return qdArea;
		}else if (length==2) {
			String s = split[1];
			regionName = getQzArea(s);
			qdArea = getQdArea(regionName);

		}else if (length==3) {
			String s = split[2];
			regionName = getQzArea(s);
			qdArea = getQdArea(regionName);
		}
		if (qdArea==null) {
			qdArea="0";
		}
		return qdArea;
	}

	/**
	 * 获取当前城市原文，经过巧达格式转换后的
	 * @param residence
	 */
	public String getCityCnt(String residence) throws IOException {
		String cityStr = residence;
		String[] split = cityStr.split(",");
		String regionName = "";
		int length = split.length;
		if (length==0) {
			return regionName;
		}
		if (length==1) {
			return regionName;
		}else if (length==2) {
			String s = split[1];
			regionName = getQzArea(s);

		}else if (length==3) {
			String s = split[2];
			regionName = getQzArea(s);
		}
		if (regionName==null) {
			regionName="";
		}
		return regionName;
	}

	/**
	 * 获取行业trade字典值及原文
	 * @param currentIndustry
	 * @return
	 * @throws IOException
	 */
	public Map<String, String[]> getTradeAndCnt(String currentIndustry) throws IOException {
		String[] split = currentIndustry.split("###");
		String result = "";
		String result_cnt = "";
		Map<String, String[]> map = new HashMap<>();
		if (split.length==0) {
			map.put("trade", result.split(","));
			map.put("trade_cnt", result_cnt.split(","));
			return map;
		}
		int a = split.length;
		for (int i=0; i<a; i++) {
			String[] sp = split[i].split(",");
			if (sp.length==0) {
				continue;
			}
			if (sp.length==1) {
				//一级标题
				String qzTrade = getQzTrade(sp[0]);
				String qdTrade = getQdTrade(qzTrade);
				if (qzTrade==null && qdTrade==null) {
					continue;
				}
				if (qzTrade==null) {
					qzTrade="";
				}
				if (qdTrade==null) {
					qdTrade="0";
				}
				result = result+qdTrade+",";
				result_cnt = result_cnt+qzTrade+",";
			}
			if (sp.length==2) {
				//二级标题取第二个
				String qzTrade = getQzTrade(sp[1]);
				String qdTrade = getQdTrade(qzTrade);
				if (qzTrade==null && qdTrade==null) {
					continue;
				}
				if (qzTrade==null) {
					qzTrade="";
				}
				if (qdTrade==null) {
					qdTrade = "0";
				}
				result = result+qdTrade+",";
				result_cnt = result_cnt+qzTrade+",";
			}
		}
//		if ("".equals(result) || "".equals(result_cnt)) {
//			return null;
//		}

		map.put("trade", result.split(","));
		map.put("trade_cnt", result_cnt.split(","));
		return map;
	}

//	/**
//	 * 获取行业trade原文
//	 * @param currentIndustry
//	 * @return
//	 * @throws IOException
//	 */
//	public String[] getTradeCnt(String currentIndustry) throws IOException {
//		String[] split = currentIndustry.split("###");
//		String result = "";
//		String[] splitRes = null;
//		if (split.length==0) {
//			return null;
//		}
//		int a = split.length;
//		for (int i=0; i<a; i++) {
//			String[] sp = split[i].split(",");
//			if (sp.length==0) {
//				continue;
//			}
//			if (sp.length==1) {
//				//一级标题
//				String qzTrade = getQzTrade(sp[0]);
//				result = result+qzTrade+",";
//			}
//			if (sp.length==2) {
//				//二级标题取第二个
//				String qzTrade = getQzTrade(sp[1]);
//				result = result+qzTrade+",";
//			}
//		}
//		splitRes = result.split(",");
//		return splitRes;
//	}

//	public String[] getTargetJob() {
//		return null;
//	}

	/**
	 * 教育经历原文
	 * @param jsonIn2
	 * @return
	 */
// "2010.09 - 2014.06 郑州华信学院 艺术设计 本科"
	public String getEducationCnt(JSONObject jsonIn2) {
		String educationCnt = "";
		if (jsonIn2==null || "".equals(jsonIn2.toString())) {
			return educationCnt;
		}
		JSONObject educationBackground = (JSONObject) jsonIn2.get("EducationBackground");
		JSONArray education;
		if (educationBackground==null) {
			education = null;
		} else {
			education = (JSONArray) educationBackground.get("Education");
		}
		int a;
		if (education==null) {
			a = 0;
		}else {
			a = education.size();
		}
		for (int i=0; i<a; i++) {
			JSONObject edu = (JSONObject) education.get(i);
			Object per = edu.get("Period");
			if (per==null || "".equals(per.toString())) {
				continue;
			}
			String period = edu.get("Period")==null?"":edu.get("Period").toString();
			String schoolName_cn = edu.get("SchoolName_CN")==null?"":edu.get("SchoolName_CN").toString();
			String majorName_cn = edu.get("MajorName_CN")==null?"":edu.get("MajorName_CN").toString();
			String degree = edu.get("Degree")==null?"":edu.get("Degree").toString();
			Map<String, Object> degreeMap = getDegree(degree);
			String backgd = degreeMap.get("backgd").toString();

			educationCnt = educationCnt + period.replace("-", ".").replace("/", "-")+" "+schoolName_cn+ " "+majorName_cn+" "+backgd+"; ";

		}

		return educationCnt;
	}

	/**
	 * 获取第一份工作时间及原文
	 * @param jsonIn1
	 * @return
	 */
	public Map<String, Object> getFstJobDate(JSONObject jsonIn1, JSONObject jsonIn2) throws ParseException {
		Map<String, Object> map = new HashMap<>();
		if (jsonIn1==null || "".equals(jsonIn1.toString())) {
			map.put("fst_job_date", 0l);//第一份工作开始时间
			map.put("fst_job_date_cnt", "");//第一份工作开始时间原文yyyy.MM.dd
			return map;
		}
		Object startWorkTimeObj = jsonIn1.get("StartWorkTime");
		if (startWorkTimeObj==null) {
			JSONObject workExperience = (JSONObject) jsonIn2.get("WorkExperience");
			JSONArray work;
			if (workExperience==null) {
				map.put("fst_job_date", 0l);
				map.put("fst_job_date_cnt", "");
				return map;
			} else {
				if (workExperience.get("Work")==null) {
					map.put("fst_job_date", 0l);
					map.put("fst_job_date_cnt", "");
					return map;
				}else {
					work = (JSONArray) workExperience.get("Work");
				}
			}
			Long startYear = getOldWorkTimeInfo(work);
			map.put("fst_job_date", startYear);
			//转换为yyyyMMdd
			//时间戳转化为Sting或Date
			String dateStr = TimeUtil.getDateStr(startYear);
			map.put("fst_job_date_cnt", dateStr);
		} else {
			Long startWorkTime = 0l;
			try {
				startWorkTime = Long.valueOf(startWorkTimeObj.toString());
			} catch (Exception e) {
				JSONObject workExperience = (JSONObject) jsonIn2.get("WorkExperience");
				JSONArray work;
				if (workExperience==null) {
					map.put("fst_job_date", 0l);
					map.put("fst_job_date_cnt", "");
					return map;
				} else {
					if (workExperience.get("Work")==null) {
						map.put("fst_job_date", 0l);
						map.put("fst_job_date_cnt", "");
						return map;
					}else {
						work = (JSONArray) workExperience.get("Work");
					}
				}
				Long startYear = getOldWorkTimeInfo(work);
				map.put("fst_job_date", startYear);
				//转换为yyyyMMdd
				//时间戳转化为Sting或Date
				String dateStr = TimeUtil.getDateStr(startYear);
				map.put("fst_job_date_cnt", dateStr);
				return map;
			}

			map.put("fst_job_date", startWorkTime);
			//转换为yyyyMMdd
			//时间戳转化为Sting或Date
			String dateStr = TimeUtil.getDateStr(startWorkTime);
			map.put("fst_job_date_cnt", dateStr);
		}

		return map;
	}

	/**
	 * 获取最近工作时间及原文
	 * @param jsonIn2
	 * @return
	 */
	public Map<String, Object> getLstJobDate(JSONObject jsonIn2) throws ParseException {
		Map<String, Object> map = new HashMap<>();
		if (jsonIn2==null || "".equals(jsonIn2.toString())) {
			map.put("lst_job_date", 0l);//最近一份工作离职结束时间 yyyyMMdd
			map.put("lst_job_date_cnt", "");//最近一份工作离职时间原文
			return map;
		}
		JSONObject workExperience = (JSONObject) jsonIn2.get("WorkExperience");
		JSONArray work;
		if (workExperience==null) {
			map.put("lst_job_date", 0l);
			map.put("lst_job_date_cnt", "");
			return map;
		} else {
			if (workExperience.get("Work")==null) {
				map.put("lst_job_date", 0l);
				map.put("lst_job_date_cnt", "");
				return map;
			}else {
				work = (JSONArray) workExperience.get("Work");
			}
		}
		Long endYear = getLastWorkTimeInfo(work);
		if (endYear==2051193600l) {//整数2051193600代表至今
			map.put("lst_job_date", 0l);
			//转换为yyyyMMdd
			//时间戳转化为Sting或Date
			String dateStr = TimeUtil.getDateStr(endYear);
			map.put("lst_job_date_cnt", "至今");
		} else {
			map.put("lst_job_date", endYear);
			//转换为yyyyMMdd
			//时间戳转化为Sting或Date
			String dateStr = TimeUtil.getDateStr(endYear);
			map.put("lst_job_date_cnt", dateStr);
		}

		return map;
	}

	//获取几个经历中，最近的是数组几
	public Long getLastWorkTimeInfo(JSONArray jsonArray) {
		int size = jsonArray.size();
		Map<Integer, Long> map = new HashMap<>();
		List<Long> list = new ArrayList<>();
		if (size<1) {
			return null;
		}
		for (int i=0; i<size; i++) {
			try {
				JSONObject json = (JSONObject) jsonArray.get(i);
				Long endYear = Long.valueOf(json.get("EndYear").toString());
				list.add(endYear);
			} catch (Exception e) {
				continue;
			}
		}
		//判断值最大的那个，获取编号key
		Long i = MapAndListUtil.listArrayMaxValue(list);
		return i;
	}

	//获取几个经历中，最远的是数组几
	public Long getOldWorkTimeInfo(JSONArray jsonArray) {
		int size = jsonArray.size();
		Map<Integer, Long> map = new HashMap<>();
		List<Long> list = new ArrayList<>();
		if (size<1) {
			return null;
		}
		for (int i=0; i<size; i++) {
			try {
				JSONObject json = (JSONObject) jsonArray.get(i);
				Long endYear = Long.valueOf(json.get("StartYear").toString());
				list.add(endYear);
			} catch (Exception e) {
				continue;
			}
		}
		//判断值最小的那个，获取编号key
		Long i = MapAndListUtil.listArrayMinValue(list);
		return i;
	}

	/**
	 * 获取语言集合
	 * @param jsonIn2
	 * @return
	 */
	public Collection<Language> getLanguage(JSONObject jsonIn2) {
		Collection<Language> languages = new LinkedHashSet<Language>();
		try {
			JSONObject languageCapability = (JSONObject) jsonIn2.get("LanguageCapability");
			JSONArray languageArr;
			if (languageCapability==null || "".equals(languageCapability.toString())) {
				languageArr = null;
			} else {
				languageArr = (JSONArray) languageCapability.get("Language");
			}
			int size;
			if (languageArr==null) {
				size = 0;
			} else {
				size = languageArr.size();
			}
			if (languageArr==null || "".equals(languageArr.toString()) || size==0) {
				Language language = new Language();
				language.setLanguage("");
				language.setAll_level("");
				language.setLang_cnt("");
				language.setLang_level("");
				language.setLiteracy("");
				language.setLiteracy_cnt("");
				language.setVerbal("");
				language.setVerbal_cnt("");

				languages.add(language);
				return languages;
			}
			for (int i=0; i<size; i++) {
				Object o = languageArr.get(i);
				Language language = new Language();
				if (o==null || "".equals(o.toString())) {
					language.setLanguage("");//语言ID --字典
					language.setAll_level("");//听说读写能力
					language.setLang_cnt("");//语言原文
					language.setLang_level("");//语言等级
					language.setLiteracy("");///不限:1	一般:2 	良好:3  	熟练:4 	精通:5
					language.setLiteracy_cnt("");//读写能力原读写能力"文
					language.setVerbal("");//听说能力
					language.setVerbal_cnt("");//听说能力原文
					languages.add(language);
					continue;
				}
				JSONObject lan = (JSONObject) o;
				Map<String, String> typeMap = getLanguageType(lan.get("Language")==null?"":lan.get("Language").toString());
				Map<String, String> lsMap = getLanguageLevel(lan.get("ListenSpeak")==null?"":lan.get("ListenSpeak").toString());
				Map<String, String> rwMap = getLanguageLevel(lan.get("ReadWrite")==null?"":lan.get("ReadWrite").toString());
				language.setLanguage(typeMap.get("langtype"));//语言ID --字典
				language.setLang_cnt(typeMap.get("langtype_cnt"));//语言原文
				language.setLiteracy(rwMap.get("level"));///不限:1	一般:2 	良好:3  	熟练:4 	精通:5
				language.setLiteracy_cnt(rwMap.get("level_cnt"));//读写能力原读写能力原文
				language.setVerbal(lsMap.get("level"));//听说能力
				language.setVerbal_cnt(lsMap.get("level_cnt"));//听说能力原文
				language.setAll_level("");//听说读写能力
				language.setLang_level("");//语言等级

				languages.add(language);
			}

			return languages;
		} catch (Exception e) {
			return null;
		}

	}

	/**
	 * 获取语言原文
	 * @param collection
	 * @return
	 */
	public String getLanguageCnt(Collection<Language> collection) {
		String languageCnt = "";
		if (collection==null || collection.size()<1) {
			return languageCnt;
		}
		for (Language la : collection) {
			languageCnt = languageCnt + la.getLang_cnt()+":读写能力"+la.getLiteracy_cnt()+" | "+"听说能力"+la.getVerbal_cnt()+";";
		}
		languageCnt = languageCnt.substring(0,languageCnt.length()-1);
		return languageCnt;
	}

	/**
	 * 语言种类转换
	 * @param str
	 * @return
	 */
	public Map<String, String> getLanguageType(String str) {
		Map<String, String> map = new HashMap<>();
		switch (str) {
			case "10" :
				map.put("langtype", "1");
				map.put("langtype_cnt", "英语");
				break;
			case "11" :
				map.put("langtype", "2");
				map.put("langtype_cnt", "日语");
				break;
			case "12" :
				map.put("langtype", "3");
				map.put("langtype_cnt", "法语");
				break;
			case "13" :
				map.put("langtype", "4");
				map.put("langtype_cnt", "德语");
				break;
			case "14" :
				map.put("langtype", "5");
				map.put("langtype_cnt", "俄语");
				break;
			case "15" :
				map.put("langtype", "6");
				map.put("langtype_cnt", "韩语/朝鲜语");
				break;
			case "16" :
				map.put("langtype", "7");
				map.put("langtype_cnt", "西班牙语");
				break;
			case "17" :
				map.put("langtype", "8");
				map.put("langtype_cnt", "葡萄牙语");
				break;
			case "18" :
				map.put("langtype", "9");
				map.put("langtype_cnt", "阿拉伯语");
				break;
			case "19" :
				map.put("langtype", "10");
				map.put("langtype_cnt", "意大利语");
				break;
			case "20" :
				map.put("langtype", "11");
				map.put("langtype_cnt", "普通话");
				break;
			case "21" :
				map.put("langtype", "12");
				map.put("langtype_cnt", "粤语");
				break;
			case "23" :
				map.put("langtype", "13");
				map.put("langtype_cnt", "闽南语");
				break;
			case "22" :
				map.put("langtype", "14");
				map.put("langtype_cnt", "上海话");
				break;
			default:
				map.put("langtype", "15");
				map.put("langtype_cnt", "其他");
				break;
		}
		return map;
	}

	/**
	 * 语言能力等级转换
	 * @param str
	 * @return
	 */
	public Map<String, String> getLanguageLevel(String str) {
		Map<String, String> map = new HashMap<>();
		//巧达：不限:1	一般:2 	良好:3  	熟练:4 	精通:5
		//全职：一般:1 	良好:2  	熟练:3 	精通:4
		switch (str) {
			case "1" :
				map.put("level", "2");
				map.put("level_cnt", "一般");
				break;
			case "2" :
				map.put("level", "3");
				map.put("level_cnt", "良好");
				break;
			case "3" :
				map.put("level", "4");
				map.put("level_cnt", "熟练");
				break;
			case "4" :
				map.put("level", "5");
				map.put("level_cnt", "精通");
				break;
			default:
				map.put("level", "1");
				map.put("level_cnt", "不限");
				break;
		}
		return map;
	}

	/**
	 * 获取项目集合
	 * @param jsonIn2
	 * @return
	 * @throws ParseException
	 */
	public Collection<Projects> getProjects(JSONObject jsonIn2) throws ParseException {
		Collection<Projects> projectsList = new LinkedHashSet<Projects>();
		try {
			JSONObject pm = (JSONObject) jsonIn2.get("ProjectManagement");
			if (pm==null || "".equals(pm.toString())) {
				Projects projects = new Projects();
				projects.setAchievement("");
				projects.setCur_company("");
				projects.setDescription("");
				projects.setDev_tools("");
				projects.setDuty("");
				projects.setEnv_hardware("");
				projects.setEnv_sofeware("");
				projects.setEtime(0l);
				projects.setPosition("");
				projects.setProject_name("");
				projects.setStime(0l);
				projects.setTime_cnt("");

				projectsList.add(projects);
				return projectsList;
			}
			JSONArray projectArr = (JSONArray) pm.get("Project");
			if (projectArr==null || "".equals(projectArr) || projectArr.size()==0) {
				Projects projects = new Projects();
				projects.setAchievement("");
				projects.setCur_company("");
				projects.setDescription("");
				projects.setDev_tools("");
				projects.setDuty("");
				projects.setEnv_hardware("");
				projects.setEnv_sofeware("");
				projects.setEtime(0l);
				projects.setPosition("");
				projects.setProject_name("");
				projects.setStime(0l);
				projects.setTime_cnt("");
				projectsList.add(projects);
				return projectsList;
			}
			int size = projectArr.size();
			for (int i=0; i<size; i++) {
				JSONObject pr = (JSONObject) projectArr.get(i);
				Projects projects = new Projects();
				String period = "";
				try {
					period = (pr.get("Period")==null||"".equals(pr.get("Period").toString()))?"":getWorkTimeCnt(pr.get("Period").toString());
				} catch (Exception e) {
					period = "";
				}
				if ("".equals(period)) {
					projects.setStime(0l);//开始时间
					projects.setEtime(0l);//结束时间
				} else {
					Map<String, Long> periodMap = getStimeAndEtime(pr.get("Period").toString());
					projects.setStime(periodMap.get("stime"));//开始时间
					projects.setEtime(periodMap.get("etime"));//结束时间
				}
				projects.setTime_cnt(period);//时间原文
				projects.setAchievement("");//项目业绩
				projects.setCur_company("");//所在公司
				projects.setDescription(pr.get("RoleAndSummy_CN")==null?"":pr.get("RoleAndSummy_CN").toString());//项目描述（可能包含职责）
				Object developTool_cn = pr.get("DevelopTool_CN");
				if (developTool_cn==null) {
					projects.setDev_tools("");//开发工具
				} else {
					projects.setDev_tools(pr.get("DevelopTool_CN").toString());//开发工具
				}
				projects.setDuty("");//职责
				Object hardwareEnvironment_cn = pr.get("HardwareEnvironment_CN");
				if (hardwareEnvironment_cn==null) {
					projects.setEnv_hardware("");//硬件环境描述
				} else {
					projects.setEnv_hardware(pr.get("HardwareEnvironment_CN").toString());//硬件环境描述
				}
				Object softwareEnvironment_cn = pr.get("SoftwareEnvironment_CN");
				if (softwareEnvironment_cn==null) {
					projects.setEnv_sofeware("");//软件环境描述
				} else {
					projects.setEnv_sofeware(pr.get("SoftwareEnvironment_CN").toString());//软件环境描述
				}
				Object position_cn = pr.get("Position_CN");
				if (position_cn==null) {
					projects.setPosition("");//职务
				} else {
					projects.setPosition(pr.get("Position_CN").toString());//职务
				}
				Object name_cn = pr.get("Name_CN");
				if (name_cn==null) {
					projects.setProject_name("");//项目名称
				} else {
					projects.setProject_name(pr.get("Name_CN").toString());//项目名称
				}

				projectsList.add(projects);
			}
			return projectsList;
		} catch (Exception e) {
			return null;
		}

	}


	/**
	 * 获取项目原文集合
	 * @param collection
	 * @return
	 */
	public Collection<ProjectsCnt> getProjectsCnts(Collection<Projects> collection) {
		Collection<ProjectsCnt> projectCnts = new LinkedHashSet<ProjectsCnt>();
		try {
			String content = "";
			if (collection==null || collection.size()<1) {
				ProjectsCnt pcnt = new ProjectsCnt();
				pcnt.setContent(content);
				projectCnts.add(pcnt);
				return projectCnts;
			}
			for (Projects pr : collection) {
				content = pr.getTime_cnt()+" "+pr.getCur_company()+" 软件环境："+pr.getEnv_sofeware()+" 硬件环境：" +pr.getEnv_hardware()+
						" 开发工具："+pr.getDev_tools()+" 责任描述："+pr.getDuty()+" 项目描述："+pr.getDescription();
				ProjectsCnt pcnt = new ProjectsCnt();
				pcnt.setContent(content);
				projectCnts.add(pcnt);
			}

			return projectCnts;
		} catch (Exception e) {
			return null;
		}
	}

	/**
	 * 获取skills职业技能水平
	 * @param jsonIn2
	 * @return
	 */
	public Collection<Skills> getSkills(JSONObject jsonIn2) {
		Collection<Skills> skillses = new LinkedHashSet<>();
		try {
			JSONObject skillAndStrength = (JSONObject) jsonIn2.get("SkillAndStrength");
			if (skillAndStrength==null || "".equals(skillAndStrength.toString())) {
				Skills skills = new Skills();
				skills.setHow_long_month("");
				skills.setLevel("");
				skills.setLevel_cnt("");
				skills.setSkill("");

				skillses.add(skills);
				return skillses;
			}
			JSONArray skillArr = (JSONArray) skillAndStrength.get("Skill");
			int size = 0;
			if (skillArr==null) {
				size = 0;
			} else {
				size = skillArr.size();
			}
			if (skillArr==null || "".equals(skillArr.toString()) || size==0) {
				Skills skills = new Skills();
				skills.setHow_long_month("");
				skills.setLevel("");
				skills.setLevel_cnt("");
				skills.setSkill("");

				skillses.add(skills);
				return skillses;
			}
			for (int i=0; i<size; i++) {
				JSONObject skill = (JSONObject) skillArr.get(i);
				if (skill==null) {
					continue;
				}
				Skills skills = new Skills();
				Object name_cn = skill.get("SkillName_CN");
				Object level = skill.get("Level");
				Object useTime = skill.get("UseTime");
				if (name_cn==null) {
					skills.setSkill("");//技能名称
				}else {
					skills.setSkill(name_cn.toString());//技能名称
				}
				if (level==null) {
					skills.setLevel("");//技能水平 //不限:1	一般:2	良好:3  熟练:4 	精通:5
					skills.setLevel_cnt("");//技能水平原文
				}else {
					Map<String, String> skillLevelMap = getSkillLevel(level.toString());
					skills.setLevel(skillLevelMap.get("level"));//技能水平 //不限:1	一般:2	良好:3  熟练:4 	精通:5
					skills.setLevel_cnt(skillLevelMap.get("level_cnt"));//技能水平原文
				}
				if (useTime==null) {
					skills.setHow_long_month("");//使用时间原文
				}else {
					skills.setHow_long_month(useTime.toString()+"个月");//使用时间原文
				}

				skillses.add(skills);
			}
			return skillses;
		} catch (Exception e) {
			return null;
		}
	}

	/**
	 * 获取职业技能原文
	 * @param collection
	 * @return
	 */
	public String getSkillsCnt(Collection<Skills> collection) {
		String skillsCnt = "";
		if (collection==null || collection.size()<1) {
			return skillsCnt;
		}
		for (Skills sk : collection) {
			skillsCnt = skillsCnt+sk.getSkill()+":"+sk.getLevel_cnt()+" | "+sk.getHow_long_month()+ "";
		}
		return skillsCnt;
	}

	/**
	 * 获取职能技巧水平
	 * @param level
	 * @return
	 */
	public Map<String, String> getSkillLevel(String level) {
		Map<String, String> map = new HashMap<>();
		switch (level) {//巧达：不限:1	一般:2	良好:3  熟练:4 	精通:5
			case "1"://1初级2熟练3精通
				map.put("level", "3");
				map.put("level_cnt", "良好");
				break;
			case "2":
				map.put("level", "4");
				map.put("level_cnt", "熟练");
				break;
			case "3":
				map.put("level", "5");
				map.put("level_cnt", "精通");
				break;
			default:
				map.put("level", "2");
				map.put("level_cnt", "一般");
				break;
		}
		return map;
	}

	/**
	 * 获取培训集合
	 * @param jsonIn2
	 * @return
	 */
	public Collection<Training> getTrainings(JSONObject jsonIn2) throws ParseException {
		Collection<Training> trainings = new LinkedHashSet<>();
		try {
			JSONObject traing = (JSONObject) jsonIn2.get("Traing");
			JSONArray traingRecord;
			if (traing==null || "".equals(traing.toString())) {
				traingRecord = null;
			} else {
				traingRecord = (JSONArray) traing.get("TraingRecord");
			}
			int size = 0;
			if (traingRecord==null) {
				size = 0;
			} else {
				size = traingRecord.size();
			}
			if (traingRecord==null || "".equals(traingRecord) ||size==0) {
				Training train = new Training();
				train.setStime(0l);//培训开始时间yyyyMMdd
				train.setEtime(0l);//培训结束时间yyyyMMdd
				train.setTime_cnt("");//培训结束时间原文
				train.setAgency("");//机构名
				train.setCer_name("");//证书名
				train.setCourse("");//培训课程
				train.setDescription("");//课程描述
				train.setAddress("");//培训地点

				trainings.add(train);
				return trainings;
			}
			for (int i=0; i<size; i++) {
				JSONObject tr = (JSONObject) traingRecord.get(i);
				if (tr==null) {
					continue;
				}
				Object insituation_cnObj = tr.get("Insituation_CN");
				if (insituation_cnObj==null) {
					Training train = new Training();
					train.setStime(0l);//培训开始时间yyyyMMdd
					train.setEtime(0l);//培训结束时间yyyyMMdd
					train.setTime_cnt("");//培训结束时间原文
					train.setAgency("");//机构名
					train.setCer_name("");//证书名
					train.setCourse("");//培训课程
					train.setDescription("");//课程描述
					train.setAddress("");//培训地点

					trainings.add(train);
					break;
				}
				String insituation_cn = tr.get("Insituation_CN").toString();
				if (insituation_cn==null || "".equals(insituation_cn) || "null".equals(insituation_cn)) {
					continue;
				}
				String duration_cn = tr.get("Duration_CN")==null?"":tr.get("Duration_CN").toString();
				String date = tr.get("Date")==null?"":tr.get("Date").toString();
				String certificate_cn = tr.get("Certificate_CN")==null?"":tr.get("Certificate_CN").toString();
				String programmeName_cn = tr.get("ProgrammeName_CN")==null?"":tr.get("ProgrammeName_CN").toString();
				String description_cn = tr.get("Description_CN")==null?"":tr.get("Description_CN").toString();
				String location_cn = tr.get("Location_CN")==null?"":tr.get("Location_CN").toString();
				Map<String, Object> trainTime = getTrainTime(date, duration_cn);
				Training train = new Training();
				train.setStime(Long.valueOf(trainTime.get("stime")==null?"0":trainTime.get("stime").toString()));//培训开始时间yyyyMMdd
				train.setEtime(Long.valueOf(trainTime.get("etime")==null?"0":trainTime.get("etime").toString()));//培训结束时间yyyyMMdd
				train.setTime_cnt(trainTime.get("time_cnt")==null?"":trainTime.get("time_cnt").toString());//培训结束时间原文
				train.setAgency(insituation_cn);//机构名
				train.setCer_name(certificate_cn);//证书名
				train.setCourse(programmeName_cn);//培训课程
				train.setDescription(description_cn);//课程描述
				train.setAddress(location_cn);//培训地点

				trainings.add(train);
			}
			return trainings;
		} catch (Exception e) {
			return null;
		}

	}

	/**
	 * 获取培训日期时间
	 * @param date
	 * @param duration_cn
	 * @return
	 * @throws ParseException
	 */
	public Map<String, Object> getTrainTime(String date, String duration_cn) throws ParseException {
		Map<String, Object> map = new HashMap<>();
		if (StringUtil.isEmpty(date) ||StringUtil.isEmpty(duration_cn)) {
			map.put("stime",0l);
			map.put("etime",0l);
			map.put("time_cnt","");
			return map;
		}
		try {
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM");
			Date parse = sf.parse(date);
			long l = parse.getTime() / 1000;
			String[] split = duration_cn.split("天");
			long l1 = Long.valueOf(split[0]) * 24 * 60 * 60 * 1000;
			long ls = l+l1;
			String dateStr = TimeUtil.getDateStr(ls);
			map.put("stime",l);
			map.put("etime",ls);
			map.put("time_cnt", duration_cn+".01-"+dateStr);
			return map;
		}catch (Exception e) {
			map.put("stime",0l);
			map.put("etime",0l);
			map.put("time_cnt","");
			return map;
		}

	}

	/**
	 * 获取党派信息
	 * @param jsonIn1
	 * @return
	 */
	public Map<String, Object> getPoliticalStatus(JSONObject jsonIn1) {
		Object politicalStatusObj = jsonIn1.get("PoliticalStatus");
		String politicalStatus = "";
		if (politicalStatusObj==null) {
			politicalStatus = "";
		} else {
			politicalStatus = jsonIn1.get("PoliticalStatus").toString();
		}

		Map<String, Object> map = new HashMap<>();
		switch (politicalStatus) {
			case "1"://中共党员
				map.put("type", 1l);
				map.put("type_cnt", "中共党员(含预备党员)");
				break;
			case "2"://共青团员
				map.put("type", 2l);
				map.put("type_cnt", "团员");
				break;
			case "3"://群众
				map.put("type", 3l);
				map.put("type_cnt", "群众");
				break;
			case "4"://民主党派
				map.put("type", 4l);
				map.put("type_cnt", "民主党派");
				break;
			default://5:其他
				map.put("type", 6l);
				map.put("type_cnt", "无可奉告");
				break;
		}
		return map;

	}

	/**
	 * 获取Certification证书原文
	 * @param collection
	 * @return
	 */
	public String getCertificationCnt(Collection<Certification> collection) {
		String content = "";
		if (collection==null || collection.size()<1) {
			return content;
		}
		for (Certification cer : collection) {
			content = content+TimeUtil.getDateYYYYStr(cer.getIssued())+cer.getCer_name()+cer.getDescription()+" ";
		}
		return content;
	}

	/**
	 * 原文没有，构造占位字段
	 */
	public Collection<Appendix> getAppendixList() {
		Collection<Appendix> appendices = new LinkedHashSet<>();
		Appendix appendix = new Appendix();
		appendix.setCmmt("");
		appendix.setFile("");
		appendix.setSize(0l);
		appendix.setType(0l);
		appendices.add(appendix);
		return appendices;
	}

	/**
	 * 全职网简历json数据入参转为入库json/bson格式
	 * @param jsonIn1
	 * @param jsonIn2
	 * @return
	 * @throws ParseException
	 */
	public ResumerAndStatus getResumer(JSONObject jsonIn1, JSONObject jsonIn2) throws ParseException, IOException {

		//构造ResumeTags
		ResumeTags resumeTags = getResumeTags(jsonIn1, jsonIn2);
		System.out.println("构造ResumeTags");
		//构造MetaInfo
		MetaInfo metaInfo = getMetaInfo(jsonIn1, jsonIn2, resumeTags);
		System.out.println("构造MetaInfo");
		//构造PositionInfo
		PositionInfo positionInfo = getPositionInfo(jsonIn1, jsonIn2);
		System.out.println("构造PositionInfo");
		//构造JobIntension
		JobIntension jobIntension = getJobIntension(jsonIn1, jsonIn2);
		System.out.println("构造JobIntension");
		//构造DeliverInfo
		DeliverInfo deliverInfo = getDeliverInfo(jsonIn1, jsonIn2, positionInfo, jobIntension);
		System.out.println("构造DeliverInfo");
		//放到集合里,默认一个
		Collection<DeliverInfo> deliverInfos = new LinkedHashSet<>();
		deliverInfos.add(deliverInfo);
		System.out.println("放到集合里,默认一个");
        //构造Education
        Collection<Education> educations = getEducations(jsonIn1, jsonIn2);
		System.out.println("构造Education");
		//构造Language
		Collection<Language> languages = getLanguage(jsonIn2);

		Collection<Skills> skills = getSkills(jsonIn2);
		System.out.println("构造Skills");
		//构造ResumeInfo
		ResumeInfo resumeInfo = new ResumeInfo();
        resumeInfo.setEducations(educations);
		resumeInfo.setLanguages(languages);////语言集合，可整体保存原文
		resumeInfo.setLanguage_cnt(getLanguageCnt(languages));//语言能力原文
		System.out.println("构造Language");

		Collection<Projects> projects = getProjects(jsonIn2);
		System.out.println("构造Projects");
		Collection<ProjectsCnt> projectsCnts = getProjectsCnts(projects);
		System.out.println("构造ProjectsCnt");
		resumeInfo.setProjectsList(projects);//项目集合
		resumeInfo.setProjectsCnts(projectsCnts);//项目集合原文
		resumeInfo.setSkillsList(skills);
		resumeInfo.setSkills_cnt(getSkillsCnt(skills));//技能集合原文
		System.out.println("构造SkillsCnt");

		Collection<Appendix> appendixList = getAppendixList();
		resumeInfo.setAppendices(appendixList);//附件
//		JSONObject additional = (JSONObject) jsonIn2.get("Additional");
//		JSONArray additionalList = (JSONArray) additional.get("AdditionalList");
//		int size = additionalList.size();
//		String description_cn = "";
//		for (int i=0; i<size; i++) {
//			JSONObject addition = (JSONObject) additionalList.get(i);
//			description_cn = description_cn + (String) addition.get("Description_CN");
//		}
//		resumeInfo.setAwards_in_schl(description_cn);//所获奖项（在校学习情况），原文",	// new
		resumeInfo.setAwards_in_schl("");//所获奖项（在校学习情况），原文",	// new
        Map<String, Object> higherEducationInfo = getHigherEducationInfo(jsonIn2);
        resumeInfo.setHighest_shool((String) higherEducationInfo.get("newSchoolName_cn"));//最高学历学校
        resumeInfo.setHighest_speciality((String) higherEducationInfo.get("newMajorName_cn"));//最高学历专业
		Object degree = jsonIn1.get("Degree");
		if (degree==null || Long.valueOf(degree.toString())==0l) {
			resumeInfo.setBackgd(10l);//最高学历", 		// 初中:1 高中:2 	中技:3  中专:4 大专:5 本科:6 MBA&EMBA:7 硕士:8 博士:9  	其他:10
			resumeInfo.setBackgd_cnt("其他");//最高学历原文
		}
		Map<String, Object> degreeMap = getDegree(degree==null?"":degree.toString());
		resumeInfo.setBackgd(Long.valueOf(degreeMap.get("backgd_id").toString()));//最高学历", 		// 初中:1 高中:2 	中技:3  中专:4 大专:5 本科:6 MBA&EMBA:7 硕士:8 博士:9  	其他:10
		resumeInfo.setBackgd_cnt(degreeMap.get("backgd").toString());//最高学历原文
        Map<String, Object> birthdayInfo = getBirthdayInfo(jsonIn1);
        resumeInfo.setBirthday(Long.valueOf(birthdayInfo.get("birthday").toString()));//生日(yyyyMMdd/yyyyMM)",
		resumeInfo.setBirthday_cnt((String) birthdayInfo.get("birthday_cnt"));//生日原文
		Object isHasChild = jsonIn1.get("IsHasChild");
		if (isHasChild==null || "0".equals(isHasChild.toString())) {
			resumeInfo.setChild_count(0l);//子女数量
		} else {
			resumeInfo.setChild_count(Long.valueOf(isHasChild.toString()));//子女数量
		}
        Object residenceCity = jsonIn2.get("ResidenceCity");
        if (residenceCity==null) {
            resumeInfo.setCur_city_cnt("");//城市原文，居住地
			resumeInfo.setCur_city_id(0l);//城市的id", 			//城市的id
        }else {
            String residence = residenceCity.toString();
			String cityCnt = getCityCnt(residence);
			if (cityCnt==null || "".equals(cityCnt)) {
				cityCnt="";
			}
			resumeInfo.setCur_city_cnt(cityCnt);//城市原文，居住地
			//获取城市字典
			String curCity = getCity(residence);

			if (curCity==null || "".equals(curCity)) {
				curCity = "0";
			}
			resumeInfo.setCur_city_id(Long.valueOf(curCity));//城市的id"
		}
		Map<String, Object> politicalStatus = getPoliticalStatus(jsonIn1);
		resumeInfo.setPolitics_stat(Long.valueOf(politicalStatus.get("type").toString()));
		resumeInfo.setPolitics_stat_cnt(politicalStatus.get("type_cnt").toString());
		resumeInfo.setDoc_id(0l);//证件号码
		resumeInfo.setDoc_id_cnt("");//证件原文
		resumeInfo.setDoc_id_type(Long.valueOf(getIdentityType(jsonIn2)));//证件id类型", 	// 身份证:1 	护照:2   	军人证:3     	其他:4   香港身份证:5
		resumeInfo.setDriving_lic("");//驾照信息
		resumeInfo.setEducation_cnt(getEducationCnt(jsonIn2));//教育经历集合原文
		resumeInfo.setEmail((String) jsonIn1.get("Email"));//邮箱
		resumeInfo.setExt_message("");//附加信息
		resumeInfo.setExt_url("");//附件简历URL
		Map<String, Object> fstJobDate = getFstJobDate(jsonIn1, jsonIn2);
		resumeInfo.setFst_job_date(Long.valueOf(fstJobDate.get("fst_job_date").toString()));
		resumeInfo.setFst_job_date_cnt((String) fstJobDate.get("fst_job_date_cnt"));
        Object sex = jsonIn1.get("Sex");
        if (sex==null) {
            resumeInfo.setGender(0l);//性别", // 男:1  	女:2
            resumeInfo.setGender_cnt("");//性别原文
        }else {
            if ("1".equals(jsonIn1.get("Sex").toString())) {
                resumeInfo.setGender(1l);//性别", // 男:1  	女:2
                resumeInfo.setGender_cnt(CommonUtil.GENDER_STATUS.GENDER_MAN.toString());//性别原文
            }else if ("2".equals(jsonIn1.get("Sex").toString())) {
                resumeInfo.setGender(2l);//性别", // 男:1  	女:2
                resumeInfo.setGender_cnt(CommonUtil.GENDER_STATUS.GENDER_WOMAN.toString());//性别原文
            }
        }
//        if (additionalList.size()<2) {
//            resumeInfo.setHands_on_exp("");//在校实践经验，原文",		// new
//        }else {
//            JSONObject additio = (JSONObject) additionalList.get(1);
//            if (additio==null) {
//                resumeInfo.setHands_on_exp("");//在校实践经验，原文",		// new
//            }else {
//                String s = "" + additio.get("Title_CN") + additio.get("Description_CN");
//                resumeInfo.setHands_on_exp(s);//在校实践经验，原文",		// new
//            }
//        }
		resumeInfo.setHands_on_exp("");//在校实践经验，原文",		// new

		resumeInfo.setHeight(0l);//身高", 			// 厘米
		String houseHold_cn = getQzHukou((String) jsonIn1.get("HouseHold_CN"));
		if (houseHold_cn==null) {
			houseHold_cn = "0";
		}
		resumeInfo.setHukou(Long.valueOf(houseHold_cn));//户口
		resumeInfo.setHukou_cnt((String) jsonIn1.get("HouseHold_CN"));//户口原文
		resumeInfo.setInterest("");//兴趣爱好，原文",	// new
		resumeInfo.setIs_english(0l);//是否是英文简历	//0否 1是
		resumeInfo.setLogo_path("");//头像地址
		Map<String, Object> lstJobDate = getLstJobDate(jsonIn2);
		resumeInfo.setLst_job_date(Long.valueOf(lstJobDate.get("lst_job_date").toString()));
		resumeInfo.setLst_job_date_cnt((String) lstJobDate.get("lst_job_date_cnt"));
        resumeInfo.setManage_skill(0l);
		resumeInfo.setMarriage_cnt(""+getMarriageState(jsonIn1).get("marriage_cnt"));
		resumeInfo.setMarriage_stat(Long.valueOf(getMarriageState(jsonIn1).get("marriage_stat").toString()));//婚否", 			// 未婚:1  已婚:2  保密:3  离异：4
        resumeInfo.setMobilephone((String) jsonIn1.get("Mobile"));
		resumeInfo.setName(jsonIn1.get("Name_CN")==null?"":jsonIn1.get("Name_CN").toString());
		resumeInfo.setNation(jsonIn1.get("Ethnicity_CN")==null? "":jsonIn1.get("Ethnicity_CN").toString());//民族"
		resumeInfo.setNation_cnt(jsonIn1.get("Ethnicity_CN")==null? "" : jsonIn1.get("Ethnicity_CN").toString());//民族原文
		resumeInfo.setNationality(jsonIn1.get("Nationality_CN")==null? "": jsonIn1.get("Nationality_CN").toString());
		resumeInfo.setNationality_cnt(jsonIn1.get("Nationality_CN")==null? "": jsonIn1.get("Nationality_CN").toString());
		resumeInfo.setNative_cnt(jsonIn1.get("HouseHold_CN")==null?"":jsonIn1.get("HouseHold_CN").toString());//籍贯原文
		resumeInfo.setNative_place(Long.valueOf(houseHold_cn));///籍贯原文
		resumeInfo.setNickname("");
        Object postalCode = jsonIn1.get("PostalCode");
        if (postalCode==null) {
            resumeInfo.setPostcode("");
        }else {
            resumeInfo.setPostcode(postalCode.toString());
        }

		Object qq = jsonIn1.get("QQ");
		if (qq==null || "".equals(qq.toString())) {
			resumeInfo.setQq(0l);
		}else {
			try {
				resumeInfo.setQq(Long.valueOf(qq.toString()));
			} catch (Exception e) {
				resumeInfo.setQq(0L);
			}
		}
		Object source = jsonIn2.get("Source");
		if (source==null) {
			resumeInfo.setRname("");
		}else {
			Long s = Long.valueOf(source.toString());
			if (s==0l) {
				resumeInfo.setRname("全职简历");
			}else {
				resumeInfo.setRname("");
			}
		}

        Object telephone = jsonIn1.get("Telephone");
        if (telephone==null || "0".equals(telephone.toString())) {
            resumeInfo.setTelephone("");
        }else {
            resumeInfo.setTelephone(telephone.toString());
        }
		Collection<Training> trainings = getTrainings(jsonIn2);
		resumeInfo.setTrainings(trainings);
		System.out.println("构造Training");
		Object traing = jsonIn2.get("Traing");//培训经历集合，可整体保存原文
		if(traing==null || "".equals(traing.toString())) {
			resumeInfo.setTraining_cnt("");
		}else {
			JSONObject train = (JSONObject) traing;
			JSONArray trainArr = (JSONArray) train.get("TraingRecord");
			int a = 0;
			if (trainArr==null) {
				a = 0;
			} else {
				a = trainArr.size();
			}
			if (a==0) {
				resumeInfo.setTraining_cnt("");
			}else {
				String str = "";
				for(int i=0; i<a; i++) {
					JSONObject o = (JSONObject) trainArr.get(i);
					String date = o.get("Date")==null?"":o.get("Date").toString();
					String duration_cn = o.get("Duration_CN")==null?"":o.get("Duration_CN").toString();
					String insituation_cn = o.get("Insituation_CN")==null?"":o.get("Insituation_CN").toString();
					String location_cn = o.get("Location_CN")==null?"":o.get("Location_CN").toString();
					String programmeName_cn = o.get("ProgrammeName_CN")==null?"":o.get("ProgrammeName_CN").toString();
					String certificate_cn = o.get("Certificate_CN")==null?"":o.get("Certificate_CN").toString();
					String description_cn = o.get("Description_CN")==null?"":o.get("Description_CN").toString();
					str = str+"培训时间:"+date+" , 培训时长:"+duration_cn+" , 培训机构:"+insituation_cn+" , 培训地点:"
							+location_cn+" , 培训课程:"+programmeName_cn+" , 获得证书:"+certificate_cn+" , 详细描述:"+description_cn+";";
				}
				resumeInfo.setTraining_cnt(str);
			}

		}
		resumeInfo.setWebsite("");//个人展示主页URL
		resumeInfo.setWeight(0l);//体重", 			// 公斤
		resumeInfo.setWeixin("");//微信
		resumeInfo.setAddress(jsonIn1.get("Address_CN")==null?"":jsonIn1.get("Address_CN").toString());
		Object isWorkExp = jsonIn1.get("IsWorkExp");
		if (isWorkExp==null) {
			resumeInfo.setWork_abroad(0l);//海外工作经历
			resumeInfo.setStudy_abroad(0l);//是否有海外求学经历 0无 1有",			//0无 1有
		}else {
			resumeInfo.setWork_abroad(Long.valueOf(isWorkExp.toString()));//海外工作经历
			resumeInfo.setStudy_abroad(Long.valueOf(isWorkExp.toString()));//是否有海外求学经历 0无 1有",			//0无 1有
		}
		resumeInfo.setRecommendation("");//推荐信，原文"	// new，全职没有提供
		//构造WorkCnt
		Collection<WorkCnt> workCnts = getWorkCnts(jsonIn1, jsonIn2);

		resumeInfo.setWorkCnts(workCnts);

		//构造Work
		Collection<Work> works = getWorks(jsonIn1, jsonIn2);

		resumeInfo.setWorks(works);

		//构造Certification
		Collection<Certification> certifications = getCertifications(jsonIn1, jsonIn2);
		resumeInfo.setCertifications(certifications);

		//获取certificationCnt
		String certificationCnt = getCertificationCnt(certifications);
		resumeInfo.setCertification_cnt(certificationCnt);

		//构造SelfAssessment
		Collection<SelfAssessment> selfAssessments = getSelfAssessments(jsonIn1, jsonIn2);
		resumeInfo.setSelfAssessments(selfAssessments);

		System.out.println("构造SelfAssessment");

		//构造Resumer
		QuanZhiResumer quanZhiResumer = new QuanZhiResumer();
		quanZhiResumer.setId(new ObjectId());//主键
		quanZhiResumer.setPerson_id(0L);//"用户ID，合库后的人员id，可为空，作为分片标识
		quanZhiResumer.setCreate_time(getCurrentTime());//时间戳
		quanZhiResumer.setLast_date(getRefreshTime(jsonIn1));//最后时间
		quanZhiResumer.setResume_id(0l);//简历唯一标识，合库后的简历唯一标识
		quanZhiResumer.setServer_ip(CommonUtil.SERVER);//服务器ip
		quanZhiResumer.setVersion_date(getRefreshTime(jsonIn1));//版本时间
		quanZhiResumer.setMetaInfo(metaInfo);
		quanZhiResumer.setDeliverInfos(deliverInfos);
		quanZhiResumer.setResumeInfo(resumeInfo);
		System.out.println("构造Resumer");
//		resumerRepository.save(quanZhiResumer);//数据实例化到mongodb

		//构造ResumerAndStatus
		ResumerAndStatus resumerAndStatus = new ResumerAndStatus();
		resumerAndStatus.setQuanZhiResumer(quanZhiResumer);
		resumerAndStatus.setStatus("1");
		if (positionInfo==null) {
			resumerAndStatus.setStatus("2");
			return resumerAndStatus;
		}
		if (jobIntension==null) {
			resumerAndStatus.setStatus("3");
			return resumerAndStatus;
		}
		if (deliverInfo==null) {
			resumerAndStatus.setStatus("4");
			return resumerAndStatus;
		}
		if (educations==null) {
			resumerAndStatus.setStatus("5");
			return resumerAndStatus;
		}
		if (languages==null) {
			resumerAndStatus.setStatus("6");
			return resumerAndStatus;
		}
		if (skills==null) {
			resumerAndStatus.setStatus("7");
			return resumerAndStatus;
		}
		if (projects==null) {
			resumerAndStatus.setStatus("8");
			return resumerAndStatus;
		}
		if (projectsCnts==null) {
			resumerAndStatus.setStatus("9");
			return resumerAndStatus;
		}
		if (trainings==null) {
			resumerAndStatus.setStatus("10");
			return resumerAndStatus;
		}
		if (workCnts==null) {
			resumerAndStatus.setStatus("11");
			return resumerAndStatus;
		}
		if (works==null) {
			resumerAndStatus.setStatus("12");
			return resumerAndStatus;
		}
		return resumerAndStatus;

	}



//	public static void main1(String[] args) {
//		JSONObject jsonAll = new JSONObject();
//		BsonDocument bsonDocumentA = new BsonDocument();
//		BsonDocument bsonDocument = new BsonDocument();
//		JSONObject json1 = new JSONObject();
//		JSONObject json2 = new JSONObject();
//		JSONArray jArray = new JSONArray();
//		json1.put("hehe", 34);
//		json1.put("hehe2", 365);
//		json1.put("hehe3", 37);
//		json2.put("hehe3", 37);
//		jsonAll.put("id", 12);
//		jsonAll.put("name", "zhangsan");
//		jsonAll.put("json1", json1);
//		jsonAll.put("json2", json2);
//		BsonDocument parse = bsonDocument.parse(jsonAll.toJSONString());
//		bsonDocumentA.put("jsonAll", parse);
//		System.out.println(bsonDocumentA.toString());
////		for (int i = 0; i < 2; i++) {
////			jArray.add(json1);
////			json1.put("hell04", "json2ge");
////		}
////		System.out.println(jArray);
//		BsonDocument parse2 = BsonDocument.parse(jsonAll.toJSONString());
//		System.out.println(parse2);
//		BSONObject bsonObject = new BasicBSONObject();
//		bsonObject.put("id", jsonAll);
//		Map map = bsonObject.toMap();
//		System.out.println(map.toString());
//	}


}
